]> granicus.if.org Git - clang/commitdiff
Switch default arguments over to InitializationSequence.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 22 Dec 2009 02:46:13 +0000 (02:46 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 22 Dec 2009 02:46:13 +0000 (02:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91883 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp
test/SemaCXX/default1.cpp
test/SemaTemplate/default-expr-arguments.cpp

index 13b65e3000b3ae8240932ea546b7702c44c7202f..dfb353281054b3672195d124a762b1815e1a4cfa 100644 (file)
@@ -128,8 +128,12 @@ Sema::SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
   InitializedEntity Entity = InitializedEntity::InitializeParameter(Param);
   InitializationKind Kind = InitializationKind::CreateCopy(Param->getLocation(),
                                                            EqualLoc);
-  if (CheckInitializerTypes(Arg, ParamType, Entity, Kind))
+  InitializationSequence InitSeq(*this, Entity, Kind, &Arg, 1);
+  OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind,
+                                          MultiExprArg(*this, (void**)&Arg, 1));
+  if (Result.isInvalid())
     return true;
+  Arg = Result.takeAs<Expr>();
 
   Arg = MaybeCreateCXXExprWithTemporaries(Arg);
 
index 8fb35c8c91c20351c8e9d7b4e21a8618f4cd186d..7ee052c5f9cb71f840d0269ceb12fdedd761d860 100644 (file)
@@ -2,7 +2,7 @@
 
 float global_f;
 
-void f0(int *ip = &global_f); // expected-error{{incompatible}}
+void f0(int *ip = &global_f); // expected-error{{cannot initialize}}
 
 // Example from C++03 standard
 int a = 1; 
index eab54f47b97b2ac6efbbde213f8154de87e2b29a..790208aa1d050a93eb8dd8e3700465190d7e67f2 100644 (file)
@@ -14,7 +14,7 @@ void h(int i, int j = 2, int k = 3,
        int n);// expected-error {{missing default argument on parameter 'n'}}
 
 struct S { } s;
-void i(int = s) { } // expected-error {{incompatible type}}
+void i(int = s) { } // expected-error {{no viable conversion}}
 
 struct X { 
   X(int);
index df3cc96ba2173fd7244abc1028fc923e4d7388d6..8518d7b70c2c4165f3f31e0637e7a271fd30dd29 100644 (file)
@@ -100,7 +100,7 @@ void test_x2(X2<int> x2i, X2<NotDefaultConstructible> x2n) {
 // PR5283
 namespace PR5283 {
 template<typename T> struct A {
-  A(T = 1); // expected-error 3 {{incompatible type initializing 'int', expected 'int *'}}
+  A(T = 1); // expected-error 3 {{cannot initialize a parameter of type 'int *' with an rvalue of type 'int'}}
 };
 
 struct B : A<int*> {