summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2013-02-10 19:57:27 (EST)
committerMarc-Andre Laperle2013-02-12 13:03:57 (EST)
commit5d335384e369003159a8eca5298cc83253864882 (patch)
tree22ee945f630dcfed24623373485b95db82a7e490
parentec0ec79c55811fb33c964c2a6524e96644690943 (diff)
downloadorg.eclipse.cdt-5d335384e369003159a8eca5298cc83253864882.zip
org.eclipse.cdt-5d335384e369003159a8eca5298cc83253864882.tar.gz
org.eclipse.cdt-5d335384e369003159a8eca5298cc83253864882.tar.bz2
Bug 385144 - Invalid redefinition of enum reported when enum is used asrefs/changes/72/10272/2
first parameter in constructor createBinding is called twice for the enumeration specifier because now ImplicitsAnalysis calls createType on the constructor parameter declaration. The second time it is called, it wrongly thinks the specifier is a redefinition. We can check that it's not a redefinition by comparing the ast names. Change-Id: If7fb168d578a7a59e78867d6d8154e0866d2a730 Reviewed-on: https://git.eclipse.org/r/10272 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java6
2 files changed, 14 insertions, 1 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 ff1f4ee..ef945c4 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
@@ -13,6 +13,7 @@
* Sergey Prigogin (Google)
* Thomas Corbat (IFS)
* Nathan Ridge
+ * Marc-Andre Laperle
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
@@ -7481,6 +7482,14 @@ public class AST2CPPTests extends AST2TestBase {
BindingAssertionHelper ba= getAssertionHelper();
ba.assertProblem("enum_name", 9);
}
+
+ // struct MyStruct {
+ // enum MyEnum {};
+ // MyStruct(MyEnum value) {}
+ // };
+ public void testEnumRedefinitionInStruct_385144() throws Exception {
+ parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
+ }
// class CL {
// typedef int x;
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 8afc1bf..f5762cf 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2012 IBM Corporation and others.
+ * Copyright (c) 2004, 2013 IBM Corporation 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
@@ -12,6 +12,7 @@
* Sergey Prigogin (Google)
* Thomas Corbat (IFS)
* Nathan Ridge
+ * Marc-Andre Laperle
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
@@ -405,6 +406,9 @@ public class CPPVisitor extends ASTQueries {
IBinding binding = scope.getBinding(name, false);
if (binding instanceof CPPEnumeration) {
CPPEnumeration e= (CPPEnumeration) binding;
+ if (name.equals(e.getDefinition())) {
+ return e;
+ }
if (e.isScoped() == specifier.isScoped()) {
IType ft2= e.getFixedType();
if (fixedType == ft2 || (fixedType != null && fixedType.isSameType(ft2))) {