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 3259e16e93b..72d2084be12 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 @@ -12274,6 +12274,18 @@ public class AST2CPPTests extends AST2CPPTestBase { parseAndCheckBindings(); } + // struct Waldo { + // int foo(); + // }; + // + // int main() { + // Waldo w; + // auto i1 = w, i2 = i1.foo(); // Error on 'foo' + // } + public void testAutoWithTwoDeclarators_522066() throws Exception { + parseAndCheckBindings(); + } + // constexpr int waldo = (sizeof(double) % 16); public void testSizeofDouble_506170() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); 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 2ed292cd169..9b16af473fd 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 @@ -253,13 +253,13 @@ public class CPPVisitor extends ASTQueries { // Common combinations of flags. public static final int DO_NOT_RESOLVE_PLACEHOLDERS = 0; - // Thread-local set of DeclSpecifiers for which auto types are being created. + // Thread-local set of declarators for which auto types are being created. // Used to prevent infinite recursion while processing invalid self-referencing // auto-type declarations. - private static final ThreadLocal> autoTypeDeclSpecs = - new ThreadLocal>() { + private static final ThreadLocal> autoTypeDeclarators = + new ThreadLocal>() { @Override - protected Set initialValue() { + protected Set initialValue() { return new HashSet<>(); } }; @@ -2166,8 +2166,8 @@ public class CPPVisitor extends ASTQueries { IType cannotDeduce = placeholderKind == PlaceholderKind.Auto ? ProblemType.CANNOT_DEDUCE_AUTO_TYPE : ProblemType.CANNOT_DEDUCE_DECLTYPE_AUTO_TYPE; - Set recursionProtectionSet = autoTypeDeclSpecs.get(); - if (!recursionProtectionSet.add(declSpec)) { + Set recursionProtectionSet = autoTypeDeclarators.get(); + if (!recursionProtectionSet.add(declarator)) { // Detected a self referring auto type, e.g.: auto x = x; return cannotDeduce; } @@ -2272,7 +2272,7 @@ public class CPPVisitor extends ASTQueries { } } } finally { - recursionProtectionSet.remove(declSpec); + recursionProtectionSet.remove(declarator); } }