From: Eli Friedman Date: Tue, 22 Dec 2009 02:46:13 +0000 (+0000) Subject: Switch default arguments over to InitializationSequence. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a2c19bf2330e31851330423187ec48035cab1a5;p=clang Switch default arguments over to InitializationSequence. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91883 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 13b65e3000..dfb3532810 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -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(); Arg = MaybeCreateCXXExprWithTemporaries(Arg); diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp index 8fb35c8c91..7ee052c5f9 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p5.cpp @@ -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; diff --git a/test/SemaCXX/default1.cpp b/test/SemaCXX/default1.cpp index eab54f47b9..790208aa1d 100644 --- a/test/SemaCXX/default1.cpp +++ b/test/SemaCXX/default1.cpp @@ -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); diff --git a/test/SemaTemplate/default-expr-arguments.cpp b/test/SemaTemplate/default-expr-arguments.cpp index df3cc96ba2..8518d7b70c 100644 --- a/test/SemaTemplate/default-expr-arguments.cpp +++ b/test/SemaTemplate/default-expr-arguments.cpp @@ -100,7 +100,7 @@ void test_x2(X2 x2i, X2 x2n) { // PR5283 namespace PR5283 { template 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 {