diff options
-rw-r--r-- | lib/AST/DeclCXX.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/TreeTransform.h | 10 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-expr-2.cpp | 14 |
3 files changed, 21 insertions, 9 deletions
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index b6072d8acd..206193ba81 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -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(); + } } } diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index f1888c87a4..e7400e7473 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -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. diff --git a/test/SemaTemplate/instantiate-expr-2.cpp b/test/SemaTemplate/instantiate-expr-2.cpp index 2c3ccb06e4..5351701cdc 100644 --- a/test/SemaTemplate/instantiate-expr-2.cpp +++ b/test/SemaTemplate/instantiate-expr-2.cpp @@ -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>; +} |