[cfe-commits] r91279 - in /cfe/trunk: lib/Sema/TreeTransform.h test/CodeGenCXX/constructor-convert.cpp
Douglas Gregor
dgregor at apple.com
Mon Dec 14 08:27:04 PST 2009
Author: dgregor
Date: Mon Dec 14 10:27:04 2009
New Revision: 91279
URL: http://llvm.org/viewvc/llvm-project?rev=91279&view=rev
Log:
When rebuilding CXXConstructExprs after a transformation, use
CompleteConstructorCall to perform type-checking.
Added:
cfe/trunk/test/CodeGenCXX/constructor-convert.cpp
Modified:
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=91279&r1=91278&r2=91279&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Dec 14 10:27:04 2009
@@ -1459,13 +1459,17 @@
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
OwningExprResult RebuildCXXConstructExpr(QualType T,
+ SourceLocation Loc,
CXXConstructorDecl *Constructor,
bool IsElidable,
MultiExprArg Args) {
- return getSema().BuildCXXConstructExpr(/*FIXME:ConstructLoc*/
- SourceLocation(),
- T, Constructor, IsElidable,
- move(Args));
+ ASTOwningVector<&ActionBase::DeleteExpr> ConvertedArgs(SemaRef);
+ if (getSema().CompleteConstructorCall(Constructor, move(Args), Loc,
+ ConvertedArgs))
+ return getSema().ExprError();
+
+ return getSema().BuildCXXConstructExpr(Loc, T, Constructor, IsElidable,
+ move_arg(ConvertedArgs));
}
/// \brief Build a new object-construction expression.
@@ -4723,7 +4727,8 @@
!ArgumentChanged)
return SemaRef.Owned(E->Retain());
- return getDerived().RebuildCXXConstructExpr(T, Constructor, E->isElidable(),
+ return getDerived().RebuildCXXConstructExpr(T, /*FIXME:*/E->getLocStart(),
+ Constructor, E->isElidable(),
move_arg(Args));
}
Added: cfe/trunk/test/CodeGenCXX/constructor-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/constructor-convert.cpp?rev=91279&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/constructor-convert.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/constructor-convert.cpp Mon Dec 14 10:27:04 2009
@@ -0,0 +1,19 @@
+// RUN: clang -emit-llvm -S -o - %s
+
+// PR5775
+class Twine {
+ Twine(const char *Str) { }
+};
+
+static void error(const Twine &Message);
+
+template<typename>
+struct opt_storage {
+ void f() {
+ error("cl::location(x) specified more than once!");
+ }
+};
+
+void f(opt_storage<int> o) {
+ o.f();
+}
More information about the cfe-commits
mailing list