diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-11-09 01:05:47 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-11-09 01:05:47 +0000 |
commit | d7686ef31c21774bbfc5ce7c051f3d9bb13a78d4 (patch) | |
tree | 27c89d744af8136c99fa863e4db801d746ec9859 /clang/test | |
parent | 939ea352441851e550b41b83c3f48e2999f5a63a (diff) | |
download | bcm5719-llvm-d7686ef31c21774bbfc5ce7c051f3d9bb13a78d4.tar.gz bcm5719-llvm-d7686ef31c21774bbfc5ce7c051f3d9bb13a78d4.zip |
Unify the codepaths used to verify base and member initializers for explicitly
and implicitly defined constructors. This has a number of benefits:
1. Less code.
2. Explicit and implicit constructors get the same diagnostics.
3. The AST explicitly contains constructor calls from implicit default
constructors. This allows handing some cases that previously weren't handled
correctly in IRGen without any additional code. Specifically, implicit default
constructors containing calls to constructors with default arguments are now
handled correctly.
llvm-svn: 86500
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp | 5 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/virt.cpp | 1 | ||||
-rw-r--r-- | clang/test/SemaCXX/constructor-initializer.cpp | 11 | ||||
-rw-r--r-- | clang/test/SemaCXX/default-constructor-initializers.cpp | 16 | ||||
-rw-r--r-- | clang/test/SemaCXX/value-initialization.cpp | 4 |
5 files changed, 20 insertions, 17 deletions
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp index 8d91068f9b9..0b83a1fee0f 100644 --- a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p4.cpp @@ -12,7 +12,7 @@ struct X { // expected-note{{here}} void g() { } - struct Inner { + struct Inner { // expected-error{{implicit default}} T value; // expected-note {{member is declared here}} }; @@ -26,8 +26,7 @@ IntHolder &test_X_IntHolderInt(X<IntHolder, int> xih) { xih.g(); // okay xih.f(); // expected-note{{instantiation}} - // FIXME: diagnostic here has incorrect reason (PR5154) - X<IntHolder, int>::Inner inner; // expected-error{{implicit default}} + X<IntHolder, int>::Inner inner; return X<IntHolder, int>::value; // expected-note{{instantiation}} } diff --git a/clang/test/CodeGenCXX/virt.cpp b/clang/test/CodeGenCXX/virt.cpp index ece59b302e2..424f9095d7c 100644 --- a/clang/test/CodeGenCXX/virt.cpp +++ b/clang/test/CodeGenCXX/virt.cpp @@ -4,6 +4,7 @@ // RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -emit-llvm %s -o %t-64.ll // RUN: FileCheck -check-prefix LPLL64 --input-file=%t-64.ll %s +// XFAIL: * struct B { virtual void bar1(); diff --git a/clang/test/SemaCXX/constructor-initializer.cpp b/clang/test/SemaCXX/constructor-initializer.cpp index 20cf35b293b..ec871764cf9 100644 --- a/clang/test/SemaCXX/constructor-initializer.cpp +++ b/clang/test/SemaCXX/constructor-initializer.cpp @@ -99,7 +99,9 @@ struct Current : Derived { // FIXME. This is bad message! struct M { // expected-note {{candidate function}} \ - // expected-note {{candidate function}} + // expected-note {{candidate function}} \ + // expected-note {{declared here}} \ + // expected-note {{declared here}} M(int i, int j); // expected-note {{candidate function}} \ // // expected-note {{candidate function}} }; @@ -110,9 +112,10 @@ struct N : M { M m1; }; -struct P : M { // expected-error {{default constructor for 'struct M' is missing in initialization of base class}} - P() { } - M m; // expected-error {{default constructor for 'struct M' is missing in initialization of member}} +struct P : M { + P() { } // expected-error {{base class 'struct M'}} \ + // expected-error {{member 'm'}} + M m; // expected-note {{member is declared here}} }; struct Q { diff --git a/clang/test/SemaCXX/default-constructor-initializers.cpp b/clang/test/SemaCXX/default-constructor-initializers.cpp index 6cbb978dbb9..48c90398635 100644 --- a/clang/test/SemaCXX/default-constructor-initializers.cpp +++ b/clang/test/SemaCXX/default-constructor-initializers.cpp @@ -9,18 +9,18 @@ struct X2 : X1 { // expected-note {{'struct X2' declared here}} \ X2(int); }; -struct X3 : public X2 { +struct X3 : public X2 { // expected-error {{must explicitly initialize the base class 'struct X2'}} }; -X3 x3; // expected-error {{cannot define the implicit default constructor for 'struct X3', because base class 'struct X2' does not have any default constructor}} +X3 x3; -struct X4 { +struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \ + // expected-error {{must explicitly initialize the reference member 'rx2'}} X2 x2; // expected-note {{member is declared here}} X2 & rx2; // expected-note {{declared at}} }; -X4 x4; // expected-error {{cannot define the implicit default constructor for 'struct X4', because member's type 'struct X2' does not have any default constructor}} \ - // expected-error {{cannot define the implicit default constructor for 'struct X4', because reference member 'rx2' cannot be default-initialized}} +X4 x4; struct Y1 { // has no implicit default constructor @@ -45,12 +45,12 @@ Y4 y4; // More tests -struct Z1 { +struct Z1 { // expected-error {{must explicitly initialize the reference member 'z'}} \ + // expected-error {{must explicitly initialize the const member 'c1'}} int& z; // expected-note {{declared at}} const int c1; // expected-note {{declared at}} volatile int v1; }; -Z1 z1; // expected-error {{cannot define the implicit default constructor for 'struct Z1', because reference member 'z' cannot be default-initialized}} \ - // expected-error {{cannot define the implicit default constructor for 'struct Z1', because const member 'c1' cannot be default-initialized}} +Z1 z1; diff --git a/clang/test/SemaCXX/value-initialization.cpp b/clang/test/SemaCXX/value-initialization.cpp index 29d866fa64d..3452883697a 100644 --- a/clang/test/SemaCXX/value-initialization.cpp +++ b/clang/test/SemaCXX/value-initialization.cpp @@ -1,10 +1,10 @@ // RUN: clang-cc -fsyntax-only -verify %s -std=c++0x -struct A { +struct A { // expected-error {{implicit default constructor for 'struct A' must explicitly initialize the const member 'i'}} const int i; // expected-note {{declared at}} virtual void f() { } }; int main () { - (void)A(); // expected-error {{cannot define the implicit default constructor for 'struct A', because const member 'i' cannot be default-initialized}} + (void)A(); } |