[cfe-commits] r81123 - in /cfe/trunk: lib/AST/ExprCXX.cpp lib/Sema/SemaDeclCXX.cpp test/SemaTemplate/default-expr-arguments.cpp
Anders Carlsson
andersca at mac.com
Sun Sep 6 09:54:02 PDT 2009
Author: andersca
Date: Sun Sep 6 11:54:02 2009
New Revision: 81123
URL: http://llvm.org/viewvc/llvm-project?rev=81123&view=rev
Log:
Reapply 81096, now with a fix. Spot the bug:
for (unsigned i = numargs; i < NumArgs; ++i)
Args[0] = 0;
;)
Modified:
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=81123&r1=81122&r2=81123&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Sun Sep 6 11:54:02 2009
@@ -403,6 +403,8 @@
Args = new (C) Stmt*[NumArgs];
for (unsigned i = 0; i < numargs; ++i)
Args[i] = args[i];
+ for (unsigned i = numargs; i < NumArgs; ++i)
+ Args[i] = 0;
}
}
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=81123&r1=81122&r2=81123&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Sep 6 11:54:02 2009
@@ -2899,8 +2899,8 @@
QualType DeclInitType,
Expr **Exprs, unsigned NumExprs) {
OwningExprResult TempResult =
- BuildCXXConstructExpr(/*FIXME: ConstructLoc*/ SourceLocation(),
- DeclInitType, Constructor, Exprs, NumExprs);
+ BuildCXXConstructExpr(VD->getLocation(), DeclInitType, Constructor,
+ Exprs, NumExprs);
if (TempResult.isInvalid())
return true;
Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp?rev=81123&r1=81122&r2=81123&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-expr-arguments.cpp Sun Sep 6 11:54:02 2009
@@ -20,7 +20,7 @@
}
template<typename T> struct F {
- F(T t = 10);
+ F(T t = 10); // expected-error{{cannot initialize 't' with an rvalue of type 'int'}}
void f(T t = 10); // expected-error{{cannot initialize 't' with an rvalue of type 'int'}}
};
@@ -34,6 +34,9 @@
void g3(F<int> f, F<struct S> s) {
f.f();
s.f(); // expected-note{{in instantiation of default function argument expression for 'f<struct S>' required here}}
+
+ F<int> f2;
+ F<S> s2; // expected-note{{in instantiation of default function argument expression for 'F<struct S>' required here}}
}
template<typename T> struct G {
More information about the cfe-commits
mailing list