summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Felber2012-05-23 23:14:49 (EDT)
committerSergey Prigogin2012-05-23 23:14:49 (EDT)
commit3ae34a03448b92365e000241a0987a2b4ecf29dc (patch)
treebf8319dd373f0194a17beeba267f1063ea1a64ce
parentfab94256f09f7112170f4bc3096894ecd84b2669 (diff)
downloadorg.eclipse.cdt-3ae34a03448b92365e000241a0987a2b4ecf29dc.zip
org.eclipse.cdt-3ae34a03448b92365e000241a0987a2b4ecf29dc.tar.gz
org.eclipse.cdt-3ae34a03448b92365e000241a0987a2b4ecf29dc.tar.bz2
Bug 379511 - Forward declaration in function parameter ignored by
translation unit. Modified patch by Lukas Felber.
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java11
2 files changed, 18 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index 2ec49ee..ceb452a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -27,6 +27,7 @@ import java.util.Iterator;
import junit.framework.TestSuite;
+import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
@@ -9684,4 +9685,13 @@ public class AST2CPPTests extends AST2BaseTest {
f= bh.assertNonProblem("f( 0 )", 1);
assertEquals("void (int)", ASTTypeUtil.getType(f.getType()));
}
+
+ // void foo(struct S s);
+ public void testParameterForwardDeclaration_379511() throws Exception {
+ BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
+ ICPPClassType struct= bh.assertNonProblem("S", 1, ICPPClassType.class);
+ IName[] declarations= bh.getTranslationUnit().getDeclarations(struct);
+ assertEquals(1, declarations.length);
+ assertEquals(bh.findName("S", 1), declarations[0]);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
index af69d01..7b13aa7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
@@ -13,7 +13,11 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
-import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.*;
+import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.ALLCVQ;
+import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.CVTYPE;
+import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
+import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
+import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateTypeUptoPointers;
import java.util.ArrayList;
import java.util.Arrays;
@@ -1468,8 +1472,9 @@ public class CPPVisitor extends ASTQueries {
break;
} else if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME) {
IASTNode p = name.getParent().getParent();
- if (p instanceof IASTSimpleDeclaration &&
- ((IASTSimpleDeclaration) p).getDeclarators().length == 0) {
+ if (p instanceof IASTParameterDeclaration ||
+ (p instanceof IASTSimpleDeclaration &&
+ ((IASTSimpleDeclaration) p).getDeclarators().length == 0)) {
break;
}
} else if (prop == IASTDeclarator.DECLARATOR_NAME) {