mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-06 15:55:47 +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:
parent
ec0ec79c55
commit
5d335384e3
2 changed files with 14 additions and 1 deletions
|
@ -13,6 +13,7 @@
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
* Thomas Corbat (IFS)
|
* Thomas Corbat (IFS)
|
||||||
* Nathan Ridge
|
* Nathan Ridge
|
||||||
|
* Marc-Andre Laperle
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||||
|
|
||||||
|
@ -7482,6 +7483,14 @@ public class AST2CPPTests extends AST2TestBase {
|
||||||
ba.assertProblem("enum_name", 9);
|
ba.assertProblem("enum_name", 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// struct MyStruct {
|
||||||
|
// enum MyEnum {};
|
||||||
|
// MyStruct(MyEnum value) {}
|
||||||
|
// };
|
||||||
|
public void testEnumRedefinitionInStruct_385144() throws Exception {
|
||||||
|
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
|
||||||
|
}
|
||||||
|
|
||||||
// class CL {
|
// class CL {
|
||||||
// typedef int x;
|
// typedef int x;
|
||||||
// friend void test() {
|
// friend void test() {
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
* Thomas Corbat (IFS)
|
* Thomas Corbat (IFS)
|
||||||
* Nathan Ridge
|
* Nathan Ridge
|
||||||
|
* Marc-Andre Laperle
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
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);
|
IBinding binding = scope.getBinding(name, false);
|
||||||
if (binding instanceof CPPEnumeration) {
|
if (binding instanceof CPPEnumeration) {
|
||||||
CPPEnumeration e= (CPPEnumeration) binding;
|
CPPEnumeration e= (CPPEnumeration) binding;
|
||||||
|
if (name.equals(e.getDefinition())) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
if (e.isScoped() == specifier.isScoped()) {
|
if (e.isScoped() == specifier.isScoped()) {
|
||||||
IType ft2= e.getFixedType();
|
IType ft2= e.getFixedType();
|
||||||
if (fixedType == ft2 || (fixedType != null && fixedType.isSameType(ft2))) {
|
if (fixedType == ft2 || (fixedType != null && fixedType.isSameType(ft2))) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue