1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 14:25:37 +02:00

Bug 385144 - Invalid redefinition of enum reported when enum is used as

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>
This commit is contained in:
Marc-Andre Laperle 2013-02-10 19:57:27 -05:00
parent ec0ec79c55
commit 5d335384e3
2 changed files with 14 additions and 1 deletions

View file

@ -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;

View file

@ -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))) {