From: Douglas Gregor Date: Tue, 19 May 2009 20:02:01 +0000 (+0000) Subject: Template instantiation for compound assignment operators. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6731c31150524b365138e5b8f46e6a4751a7c391;p=clang Template instantiation for compound assignment operators. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72126 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplateInstantiateExpr.cpp b/lib/Sema/SemaTemplateInstantiateExpr.cpp index e5ad0cd304..9dda383342 100644 --- a/lib/Sema/SemaTemplateInstantiateExpr.cpp +++ b/lib/Sema/SemaTemplateInstantiateExpr.cpp @@ -50,6 +50,7 @@ namespace { // FIXME: VisitMemberExpr // FIXME: CompoundLiteralExpr OwningExprResult VisitBinaryOperator(BinaryOperator *E); + OwningExprResult VisitCompoundAssignOperator(CompoundAssignOperator *E); OwningExprResult VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E); OwningExprResult VisitCXXConditionDeclExpr(CXXConditionDeclExpr *E); OwningExprResult VisitConditionalOperator(ConditionalOperator *E); @@ -283,6 +284,12 @@ TemplateExprInstantiator::VisitBinaryOperator(BinaryOperator *E) { return move(Result); } +Sema::OwningExprResult +TemplateExprInstantiator::VisitCompoundAssignOperator( + CompoundAssignOperator *E) { + return VisitBinaryOperator(E); +} + Sema::OwningExprResult TemplateExprInstantiator::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { Sema::OwningExprResult First = Visit(E->getArg(0)); diff --git a/test/SemaTemplate/instantiate-expr-3.cpp b/test/SemaTemplate/instantiate-expr-3.cpp index cf6139d0ce..892f649ef7 100644 --- a/test/SemaTemplate/instantiate-expr-3.cpp +++ b/test/SemaTemplate/instantiate-expr-3.cpp @@ -9,3 +9,32 @@ struct ImaginaryLiteral0 { template struct ImaginaryLiteral0<_Complex float>; template struct ImaginaryLiteral0; // expected-note{{instantiation}} + +namespace N1 { + struct X { }; + + int& operator+=(X&, int); // expected-note{{candidate}} +} + +namespace N2 { + long& operator+=(N1::X&, long); // expected-note{{candidate}} + + template + struct PlusEquals0 { + void f(T t, U u) { + Result r = t += u; // expected-error{{ambiguous}} + } + }; +} + +namespace N3 { + struct Y : public N1::X { + short& operator+=(long); // expected-note{{candidate}} + }; +} + +template struct N2::PlusEquals0; +template struct N2::PlusEquals0; +template struct N2::PlusEquals0; +template struct N2::PlusEquals0; +template struct N2::PlusEquals0; // expected-note{{instantiation}}