mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Bug 497668 - Avoid unnecessary name resolution during ambiguity resolution
Since resolved bindings are cached, we can get stuck with a bad binding resolved during an incorrecy branch of ambiguity resolution. Change-Id: I59bcb9f6f2b756892a56b135e8d6a1f026180728
This commit is contained in:
parent
d3d7a4e84a
commit
654907174b
2 changed files with 29 additions and 1 deletions
|
@ -6239,6 +6239,29 @@ public class AST2TemplateTests extends AST2TestBase {
|
|||
public void testTemplateIDAmbiguity_445177() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <bool, typename>
|
||||
// struct EnableIf;
|
||||
//
|
||||
// template <typename T>
|
||||
// struct EnableIf<true, T> {
|
||||
// typedef T type;
|
||||
// };
|
||||
//
|
||||
// template <typename...> struct Tuple;
|
||||
//
|
||||
// template <typename> struct TupleSize;
|
||||
//
|
||||
// template<typename... E>
|
||||
// struct TupleSize<Tuple<E...>> {
|
||||
// static constexpr int value = sizeof...(E);
|
||||
// };
|
||||
//
|
||||
// template<int I>
|
||||
// using W = typename EnableIf<(I < TupleSize<Tuple<int>>::value), int>::type;
|
||||
public void testTemplateIDAmbiguity_497668() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// template <typename T> void foo(T);
|
||||
// template <typename T> void foo(T, typename T::type* = 0);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue