diff options
author | Markus Schorn | 2009-02-03 12:14:36 +0000 |
---|---|---|
committer | Markus Schorn | 2009-02-03 12:14:36 +0000 |
commit | 155e36d7b3994372a61583002d809bd29b60c3a3 (patch) | |
tree | 4135a8b3c30a8295ee6020d04df883a34236bd12 /core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java | |
parent | c97571595e06e2ec4b32fa04518d6305e8b1b92a (diff) | |
download | org.eclipse.cdt-155e36d7b3994372a61583002d809bd29b60c3a3.tar.gz org.eclipse.cdt-155e36d7b3994372a61583002d809bd29b60c3a3.tar.xz org.eclipse.cdt-155e36d7b3994372a61583002d809bd29b60c3a3.zip |
Ambiguity handling for c++ conditions, bug 263158.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java')
-rw-r--r-- | core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java new file mode 100644 index 00000000000..49fd7bf2e5b --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousCondition.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2009 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp; + +import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; +import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.internal.core.dom.parser.ASTAmbiguousNode; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; + +/** + * Handles ambiguity between expression and declaration in a condition. + */ +public class CPPASTAmbiguousCondition extends ASTAmbiguousNode implements IASTAmbiguousCondition { + private IASTExpression fExpression; + private IASTDeclaration fDeclaration; + + public CPPASTAmbiguousCondition(IASTExpression expression, IASTSimpleDeclaration declaration) { + fExpression= expression; + fDeclaration= declaration; + + expression.setParent(this); + expression.setPropertyInParent(SUBCONDITION); + declaration.setParent(this); + declaration.setPropertyInParent(SUBCONDITION); + } + + @Override + public IASTNode[] getNodes() { + return new IASTNode[] {fExpression, fDeclaration}; + } + + @Override + protected void beforeResolution() { + // populate containing scope, so that it will not be affected by the alternative branches. + IScope scope= CPPVisitor.getContainingScope(this); + if (scope instanceof ICPPASTInternalScope) { + ((ICPPASTInternalScope) scope).populateCache(); + } + } + + public IASTExpression copy() { + throw new UnsupportedOperationException(); + } + + public IType getExpressionType() { + return null; + } +} |