[cfe-commits] r80679 - in /cfe/trunk: lib/AST/DeclCXX.cpp lib/Sema/TreeTransform.h test/SemaTemplate/instantiate-expr-2.cpp
Douglas Gregor
dgregor at apple.com
Tue Sep 1 09:58:52 PDT 2009
Author: dgregor
Date: Tue Sep 1 11:58:52 2009
New Revision: 80679
URL: http://llvm.org/viewvc/llvm-project?rev=80679&view=rev
Log:
Fix a crasher involving template instantiation of non-dependent
expressions making use of an overloaded operator. Thanks for the test
case, Anders!
Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=80679&r1=80678&r2=80679&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Tue Sep 1 11:58:52 2009
@@ -752,8 +752,10 @@
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();
+ }
}
}
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=80679&r1=80678&r2=80679&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Sep 1 11:58:52 2009
@@ -4525,16 +4525,12 @@
// 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.
Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp?rev=80679&r1=80678&r2=80679&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp Tue Sep 1 11:58:52 2009
@@ -146,3 +146,17 @@
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>;
+}
More information about the cfe-commits
mailing list