Switch more of Sema::CheckInitializerTypes over to
InitializationSequence. Specially, switch initialization of a C++
class type (either copy- or direct-initialization).
Also, make sure that we create an elidable copy-construction when
performing copy initialization of a C++ class variable. Fixes PR5826.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91750 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/condition.cpp b/test/SemaCXX/condition.cpp
index 7a51f7e..aede25e 100644
--- a/test/SemaCXX/condition.cpp
+++ b/test/SemaCXX/condition.cpp
@@ -16,8 +16,8 @@
for (;s;) ; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
switch (s) {} // expected-error {{statement requires expression of integer type ('struct S' invalid)}}
- while (struct S {} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{cannot initialize 'x' with an rvalue of type 'int'}} expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}}
- while (struct {} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{cannot initialize 'x' with an rvalue of type 'int'}} expected-error {{value of type 'struct <anonymous>' is not contextually convertible to 'bool'}}
+ while (struct S {} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{no viable conversion}} expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}} expected-note{{candidate function}}
+ while (struct {} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{no viable conversion}} expected-error {{value of type 'struct <anonymous>' is not contextually convertible to 'bool'}} expected-note{{candidate function}}
switch (enum {E} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{incompatible type}}
if (int x=0) { // expected-note 2 {{previous definition is here}}
diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp
index fca5a4a..db322f4 100644
--- a/test/SemaCXX/conversion-function.cpp
+++ b/test/SemaCXX/conversion-function.cpp
@@ -56,14 +56,14 @@
// This used to crash Clang.
struct Flip;
-struct Flop {
+struct Flop { // expected-note{{candidate function}}
Flop();
- Flop(const Flip&);
+ Flop(const Flip&); // expected-note{{candidate function}}
};
struct Flip {
- operator Flop() const;
+ operator Flop() const; // expected-note{{candidate function}}
};
-Flop flop = Flip(); // expected-error {{cannot initialize 'flop' with an rvalue of type 'struct Flip'}}
+Flop flop = Flip(); // expected-error {{conversion from 'struct Flip' to 'struct Flop' is ambiguous}}
// This tests that we don't add the second conversion declaration to the list of user conversions
struct C {
diff --git a/test/SemaCXX/converting-constructor.cpp b/test/SemaCXX/converting-constructor.cpp
index e0e614e..e78798b 100644
--- a/test/SemaCXX/converting-constructor.cpp
+++ b/test/SemaCXX/converting-constructor.cpp
@@ -27,7 +27,7 @@
FromShort(short s);
};
-class FromShortExplicitly {
+class FromShortExplicitly { // expected-note{{candidate function}}
public:
explicit FromShortExplicitly(short s);
};
@@ -36,7 +36,7 @@
FromShort fs1(s);
FromShort fs2 = s;
FromShortExplicitly fse1(s);
- FromShortExplicitly fse2 = s; // expected-error{{error: cannot initialize 'fse2' with an lvalue of type 'short'}}
+ FromShortExplicitly fse2 = s; // expected-error{{no viable conversion}}
}
// PR5519
diff --git a/test/SemaCXX/copy-initialization.cpp b/test/SemaCXX/copy-initialization.cpp
index 8df0c63..ad14923 100644
--- a/test/SemaCXX/copy-initialization.cpp
+++ b/test/SemaCXX/copy-initialization.cpp
@@ -2,17 +2,17 @@
class X {
public:
explicit X(const X&);
- X(int*); // expected-note{{candidate function}}
+ X(int*); // expected-note 2{{candidate function}}
explicit X(float*);
};
class Y : public X { };
void f(Y y, int *ip, float *fp) {
- X x1 = y; // expected-error{{no matching constructor for initialization of 'x1'; candidate is:}}
+ X x1 = y; // expected-error{{no matching constructor for initialization of 'class X'}}
X x2 = 0;
X x3 = ip;
- X x4 = fp; // expected-error{{cannot initialize 'x4' with an lvalue of type 'float *'}}
+ X x4 = fp; // expected-error{{no viable conversion}}
}
struct foo {
diff --git a/test/SemaCXX/dcl_init_aggr.cpp b/test/SemaCXX/dcl_init_aggr.cpp
index f7dc8f1..98aa721 100644
--- a/test/SemaCXX/dcl_init_aggr.cpp
+++ b/test/SemaCXX/dcl_init_aggr.cpp
@@ -115,9 +115,9 @@
B2 b2_3 = { c2, a2, a2 };
// C++ [dcl.init.aggr]p15:
-union u { int a; char* b; };
+union u { int a; char* b; }; // expected-note{{candidate function}}
u u1 = { 1 };
u u2 = u1;
-u u3 = 1; // expected-error{{cannot initialize 'u3' with an rvalue of type 'int'}}
+u u3 = 1; // expected-error{{no viable conversion}}
u u4 = { 0, "asdf" }; // expected-error{{excess elements in union initializer}}
u u5 = { "asdf" }; // expected-error{{incompatible type initializing 'char const [5]', expected 'int'}}
diff --git a/test/SemaCXX/default1.cpp b/test/SemaCXX/default1.cpp
index 497a6b1..eab54f4 100644
--- a/test/SemaCXX/default1.cpp
+++ b/test/SemaCXX/default1.cpp
@@ -22,10 +22,10 @@
void j(X x = 17);
-struct Y {
+struct Y { // expected-note 2{{candidate}}
explicit Y(int);
};
-void k(Y y = 17); // expected-error{{cannot initialize 'y' with an rvalue of type 'int'}}
+void k(Y y = 17); // expected-error{{no viable conversion}}
-void kk(Y = 17); // expected-error{{cannot initialize a value of type 'struct Y' with an rvalue of type 'int'}}
+void kk(Y = 17); // expected-error{{no viable conversion}}
diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp
index dc8eda5..454af5e 100644
--- a/test/SemaCXX/nested-name-spec.cpp
+++ b/test/SemaCXX/nested-name-spec.cpp
@@ -178,7 +178,7 @@
namespace somens {
- struct a { };
+ struct a { }; // expected-note{{candidate function}}
}
template <typename T>
@@ -189,7 +189,7 @@
// PR4452 / PR4451
foo<somens:a> a2; // expected-error {{unexpected ':' in nested name specifier}}
-somens::a a3 = a2; // expected-error {{cannot initialize 'a3' with an lvalue of type 'foo<somens::a>'}}
+somens::a a3 = a2; // expected-error {{no viable conversion}}
// typedefs and using declarations.
namespace test1 {