diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index e0aad1d4818..77519c53db8 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -6239,6 +6239,29 @@ public class AST2TemplateTests extends AST2TestBase { public void testTemplateIDAmbiguity_445177() throws Exception { parseAndCheckBindings(); } + + // template + // struct EnableIf; + // + // template + // struct EnableIf { + // typedef T type; + // }; + // + // template struct Tuple; + // + // template struct TupleSize; + // + // template + // struct TupleSize> { + // static constexpr int value = sizeof...(E); + // }; + // + // template + // using W = typename EnableIf<(I < TupleSize>::value), int>::type; + public void testTemplateIDAmbiguity_497668() throws Exception { + parseAndCheckBindings(); + } // template void foo(T); // template void foo(T, typename T::type* = 0); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateIDAmbiguity.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateIDAmbiguity.java index 6b5931de81b..091b8fe198e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateIDAmbiguity.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateIDAmbiguity.java @@ -114,7 +114,12 @@ public class CPPASTTemplateIDAmbiguity extends ASTAmbiguousNode int count= 0; for (IASTName templateName : templateNames) { if (templateName.getTranslationUnit() != null) { - IBinding b= templateName.resolveBinding(); + // It's sufficient to perform the first phase of binding resolution here, + // because template names should never resolve to two-phase bindings. + // The second phase of binding resolution, when performed for an incorrect + // variant, can cause incorrect bindings to be cached in places where they + // are hard to clear. + IBinding b= templateName.resolvePreBinding(); if (b instanceof IProblemBinding) { if (!containsFunctionTemplate(((IProblemBinding) b).getCandidateBindings())) return -1;