Fix a crasher involving template instantiation of non-dependent

expressions making use of an overloaded operator. Thanks for the test
case, Anders!

llvm-svn: 80679
This commit is contained in:
Douglas Gregor 2009-09-01 16:58:52 +00:00
parent 6cdf83c192
commit 32e2c8472e
3 changed files with 21 additions and 9 deletions

View File

@ -752,8 +752,10 @@ OverloadIterator::OverloadIterator(NamedDecl *ND) : D(0) {
if (isa<FunctionDecl>(ND) || isa<FunctionTemplateDecl>(ND))
D = ND;
else if (OverloadedFunctionDecl *Ovl = dyn_cast<OverloadedFunctionDecl>(ND)) {
D = ND;
Iter = Ovl->function_begin();
if (Ovl->size() != 0) {
D = ND;
Iter = Ovl->function_begin();
}
}
}

View File

@ -4525,16 +4525,12 @@ TreeTransform<Derived>::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
// used during overload resolution.
Sema::FunctionSet Functions;
DeclRefExpr *DRE = cast<DeclRefExpr>((Expr *)Callee.get());
OverloadedFunctionDecl *Overloads
= cast<OverloadedFunctionDecl>(DRE->getDecl());
DeclRefExpr *DRE
= cast<DeclRefExpr>(((Expr *)Callee.get())->IgnoreParenCasts());
// FIXME: Do we have to check
// IsAcceptableNonMemberOperatorCandidate for each of these?
for (OverloadedFunctionDecl::function_iterator
F = Overloads->function_begin(),
FEnd = Overloads->function_end();
F != FEnd; ++F)
for (OverloadIterator F(DRE->getDecl()), FEnd; F != FEnd; ++F)
Functions.insert(*F);
// Add any functions found via argument-dependent lookup.

View File

@ -146,3 +146,17 @@ namespace N8 {
test_plus(&x, x, x);
}
}
namespace N9 {
struct A {
bool operator==(int value);
};
template<typename T> struct B {
bool f(A a) {
return a == 1;
}
};
template struct B<int>;
}