]> granicus.if.org Git - clang/commitdiff
When rebuilding CXXConstructExprs after a transformation, use
authorDouglas Gregor <dgregor@apple.com>
Mon, 14 Dec 2009 16:27:04 +0000 (16:27 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 14 Dec 2009 16:27:04 +0000 (16:27 +0000)
CompleteConstructorCall to perform type-checking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91279 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/TreeTransform.h
test/CodeGenCXX/constructor-convert.cpp [new file with mode: 0644]

index dc848a53ab5cbed58071f86f5f4ed5bdb88899a9..b1d7f06489479bdc579b9d9a22d8d0c9a4315319 100644 (file)
@@ -1459,13 +1459,17 @@ public:
   /// 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 @@ TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
       !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));
 }
 
diff --git a/test/CodeGenCXX/constructor-convert.cpp b/test/CodeGenCXX/constructor-convert.cpp
new file mode 100644 (file)
index 0000000..6fa6d55
--- /dev/null
@@ -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();
+}