diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:02:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:02:28 +0000 |
commit | 7442d6faa2719e4e7d33a7021c406c5a4facd74d (patch) | |
tree | c72b9241553fc9966179aba84f90f17bfa9235c3 /test/SemaCXX/default-constructor-initializers.cpp | |
parent | b52119637f743680a99710ce5fdb6646da2772af (diff) |
Diffstat (limited to 'test/SemaCXX/default-constructor-initializers.cpp')
-rw-r--r-- | test/SemaCXX/default-constructor-initializers.cpp | 81 |
1 files changed, 66 insertions, 15 deletions
diff --git a/test/SemaCXX/default-constructor-initializers.cpp b/test/SemaCXX/default-constructor-initializers.cpp index e783f49826059..25c7064d59848 100644 --- a/test/SemaCXX/default-constructor-initializers.cpp +++ b/test/SemaCXX/default-constructor-initializers.cpp @@ -1,26 +1,59 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s struct X1 { // has no implicit default constructor X1(int); }; -struct X2 : X1 { // expected-note 2 {{'X2' declared here}} +struct X2 : X1 { +#if __cplusplus <= 199711L +// expected-note@-2 2 {{'X2' declared here}} +#endif + X2(int); }; -struct X3 : public X2 { // expected-error {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}} +struct X3 : public X2 { +#if __cplusplus <= 199711L +// expected-error@-2 {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}} +#else +// expected-note@-4 {{default constructor of 'X3' is implicitly deleted because base class 'X2' has no default constructor}} +#endif }; -X3 x3; // expected-note {{first required here}} - -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 here}} +X3 x3; +#if __cplusplus <= 199711L +// expected-note@-2 {{first required here}} +#else +// expected-error@-4 {{call to implicitly-deleted default constructor of 'X3'}} +#endif + +struct X4 { +#if __cplusplus <= 199711L +// expected-error@-2 {{must explicitly initialize the member 'x2'}} +// expected-error@-3 {{must explicitly initialize the reference member 'rx2'}} +#endif + + X2 x2; +#if __cplusplus <= 199711L + // expected-note@-2 {{member is declared here}} +#else + // expected-note@-4 {{default constructor of 'X4' is implicitly deleted because field 'x2' has no default constructor}} +#endif + + X2 & rx2; +#if __cplusplus <= 199711L + // expected-note@-2 {{declared here}} +#endif }; -X4 x4; // expected-note {{first required here}} - +X4 x4; +#if __cplusplus <= 199711L +// expected-note@-2 {{first required here}} +#else +// expected-error@-4 {{call to implicitly-deleted default constructor of 'X4'}} +#endif struct Y1 { // has no implicit default constructor Y1(int); @@ -43,15 +76,33 @@ Y4 y4; // More tests -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 here}} - const int c1; // expected-note {{declared here}} +struct Z1 { +#if __cplusplus <= 199711L +// expected-error@-2 {{must explicitly initialize the reference member 'z'}} +// expected-error@-3 {{must explicitly initialize the const member 'c1'}} +#endif + + int& z; +#if __cplusplus <= 199711L + // expected-note@-2 {{declared here}} +#else + // expected-note@-4 {{default constructor of 'Z1' is implicitly deleted because field 'z' of reference type 'int &' would not be initialized}} +#endif + + const int c1; +#if __cplusplus <= 199711L + // expected-note@-2 {{declared here}} +#endif volatile int v1; }; // Test default initialization which *requires* a constructor call for non-POD. -Z1 z1; // expected-note {{first required here}} +Z1 z1; +#if __cplusplus <= 199711L +// expected-note@-2 {{first required here}} +#else +// expected-error@-4 {{call to implicitly-deleted default constructor of 'Z1'}} +#endif // Ensure that value initialization doesn't use trivial implicit constructors. namespace PR7948 { |