Correct the order in which we cope with end-of-class-definition
semantics and improve our handling of default arguments. Specifically,
we follow this order:
- As soon as the see the '}' in the class definition, the class is
complete and we add any implicit declarations (default constructor,
copy constructor, etc.) to the class.
- If there are any default function arguments, parse them
- If there were any inline member function definitions, parse them
As part of this change, we now keep track of the the fact that we've
seen unparsed default function arguments within the AST. See the new
ParmVarDecl::hasUnparsedDefaultArg member. This allows us to properly
cope with calls inside default function arguments to other functions
where we're making use of the default arguments.
Made some C++ error messages regarding failed initializations more
specific.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61406 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/condition.cpp b/test/SemaCXX/condition.cpp
index d611364..43117e6 100644
--- a/test/SemaCXX/condition.cpp
+++ b/test/SemaCXX/condition.cpp
@@ -16,8 +16,8 @@
for (;s;) ; // expected-error {{expression must have bool type (or be convertible to bool) ('struct S' invalid)}}
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 {{incompatible type}} expected-error {{expression must have bool type}}
- while (struct {} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{incompatible type}} expected-error {{expression must have bool type}}
+ 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 {{expression must have bool type}}
+ 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 {{expression must have bool type}}
switch (enum {E} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{incompatible type}}
if (int x=0) { // expected-note {{previous definition is here}}
diff --git a/test/SemaCXX/constructor.cpp b/test/SemaCXX/constructor.cpp
index 536593d..68099ec 100644
--- a/test/SemaCXX/constructor.cpp
+++ b/test/SemaCXX/constructor.cpp
@@ -1,5 +1,4 @@
// RUN: clang -fsyntax-only -verify %s
-
typedef int INT;
class Foo {
@@ -37,3 +36,7 @@
y(int);
};
extern y b;
+
+struct Length {
+ Length l() const { return *this; }
+};
diff --git a/test/SemaCXX/copy-initialization.cpp b/test/SemaCXX/copy-initialization.cpp
index 5ef84de..e380cc1 100644
--- a/test/SemaCXX/copy-initialization.cpp
+++ b/test/SemaCXX/copy-initialization.cpp
@@ -13,5 +13,5 @@
X x1 = y; // expected-error{{no matching constructor for initialization of 'x1'; candidate is:}}
X x2 = 0;
X x3 = ip;
- X x4 = fp; // expected-error{{incompatible type initializing 'x4', expected 'class X'}}
+ X x4 = fp; // expected-error{{cannot initialize 'x4' with an lvalue of type 'float *'}}
}
diff --git a/test/SemaCXX/default1.cpp b/test/SemaCXX/default1.cpp
index 286be61..2844420 100644
--- a/test/SemaCXX/default1.cpp
+++ b/test/SemaCXX/default1.cpp
@@ -26,4 +26,6 @@
explicit Y(int);
};
-void k(Y y = 17); // expected-error{{incompatible type in default argument}}
+void k(Y y = 17); // expected-error{{cannot initialize 'y' with an rvalue of type 'int'}}
+
+void kk(Y = 17); // expected-error{{cannot initialize a value of type 'struct Y' with an rvalue of type 'int'}}
diff --git a/test/SemaCXX/default2.cpp b/test/SemaCXX/default2.cpp
index 863ac0e..c2873af 100644
--- a/test/SemaCXX/default2.cpp
+++ b/test/SemaCXX/default2.cpp
@@ -103,8 +103,20 @@
Z z2; // expected-error{{no matching constructor for initialization}}
Z z3(z);
}
+
+ void test_Z(const Z& z) {
+ Z z2(z); // expected-error{{no matching constructor for initialization of 'z2'}}
+ }
};
void test_Z(const Z& z) {
Z z2(z); // expected-error{{no matching constructor for initialization of 'z2'}}
}
+
+struct ZZ {
+ void f(ZZ z = g()); // expected-error{{no matching constructor for initialization}}
+
+ static ZZ g(int = 17);
+
+ ZZ(ZZ&, int = 17); // expected-note{{candidate function}}
+};