diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-10-27 16:51:19 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-10-27 16:51:19 +0000 |
commit | 115654873df4ccabe8c0515a898034d1f72cef8d (patch) | |
tree | 0f40417b7a3eb8d0de133dfb2f60b05d2954c93c /clang/test | |
parent | 50b41ed06008b2a129838a1fdbf037ad2bc8087a (diff) | |
download | bcm5719-llvm-115654873df4ccabe8c0515a898034d1f72cef8d.tar.gz bcm5719-llvm-115654873df4ccabe8c0515a898034d1f72cef8d.zip |
Generate constructor for value-initialization cases, even if the
implementation technique doesn't call the constructor at that point.
DR302. Fixes pr5296.
llvm-svn: 85249
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaCXX/value-initialization.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/value-initialization.cpp b/clang/test/SemaCXX/value-initialization.cpp new file mode 100644 index 00000000000..6b992973614 --- /dev/null +++ b/clang/test/SemaCXX/value-initialization.cpp @@ -0,0 +1,23 @@ +// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x + +struct A { + ~A(); + const int i; // expected-note {{declared at}} +}; + +struct B { + // B is a non-POD with no user-written constructor. + // It has a nontrivial generated constructor. + const int i[12]; // expected-note {{declared at}} + A a; +}; + +int main () { + // Value-initializing a "B" doesn't call the default constructor for + // "B"; it value-initializes the members of B. Therefore it shouldn't + // cause an error on generation of the default constructor for the + // following: + new B(); // expected-error {{cannot define the implicit default constructor for 'struct B', because const member 'i'}} + (void)B(); + (void)A(); // expected-error {{cannot define the implicit default constructor for 'struct A', because const member 'i'}} +} |