[cfe-commits] r72126 - in /cfe/trunk: lib/Sema/SemaTemplateInstantiateExpr.cpp test/SemaTemplate/instantiate-expr-3.cpp
Douglas Gregor
dgregor at apple.com
Tue May 19 13:02:02 PDT 2009
Author: dgregor
Date: Tue May 19 15:02:01 2009
New Revision: 72126
URL: http://llvm.org/viewvc/llvm-project?rev=72126&view=rev
Log:
Template instantiation for compound assignment operators.
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=72126&r1=72125&r2=72126&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Tue May 19 15:02:01 2009
@@ -50,6 +50,7 @@
// FIXME: VisitMemberExpr
// FIXME: CompoundLiteralExpr
OwningExprResult VisitBinaryOperator(BinaryOperator *E);
+ OwningExprResult VisitCompoundAssignOperator(CompoundAssignOperator *E);
OwningExprResult VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
OwningExprResult VisitCXXConditionDeclExpr(CXXConditionDeclExpr *E);
OwningExprResult VisitConditionalOperator(ConditionalOperator *E);
@@ -284,6 +285,12 @@
}
Sema::OwningExprResult
+TemplateExprInstantiator::VisitCompoundAssignOperator(
+ CompoundAssignOperator *E) {
+ return VisitBinaryOperator(E);
+}
+
+Sema::OwningExprResult
TemplateExprInstantiator::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
Sema::OwningExprResult First = Visit(E->getArg(0));
if (First.isInvalid())
Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp?rev=72126&r1=72125&r2=72126&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-3.cpp Tue May 19 15:02:01 2009
@@ -9,3 +9,32 @@
template struct ImaginaryLiteral0<_Complex float>;
template struct ImaginaryLiteral0<int*>; // 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<typename T, typename U, typename Result>
+ 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<N1::X, int, int&>;
+template struct N2::PlusEquals0<N1::X, long, long&>;
+template struct N2::PlusEquals0<N3::Y, long, short&>;
+template struct N2::PlusEquals0<int, int, int&>;
+template struct N2::PlusEquals0<N3::Y, int, short&>; // expected-note{{instantiation}}
More information about the cfe-commits
mailing list