diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-09-24 17:48:25 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-09-24 17:48:25 +0000 |
commit | a74948d347913c284009e0fca41b120980db3fa4 (patch) | |
tree | 1b03ccb521c321c2a94d73ef6e641115764ed707 /clang/test/SemaCXX/cxx0x-initializer-scalars.cpp | |
parent | 12757ab4cb49f64071d1cd8d6a186c9a975721fa (diff) | |
download | bcm5719-llvm-a74948d347913c284009e0fca41b120980db3fa4.tar.gz bcm5719-llvm-a74948d347913c284009e0fca41b120980db3fa4.zip |
Correctly parse braced member initializers (even in delayed parsing) and correctly pass
the information on to Sema. There's still an incorrectness in the way template instantiation
works now, but that is due to a far larger underlying representational problem.
Also add a test case for various list initialization cases of scalars, which test this
commit as well as the previous one.
llvm-svn: 140460
Diffstat (limited to 'clang/test/SemaCXX/cxx0x-initializer-scalars.cpp')
-rw-r--r-- | clang/test/SemaCXX/cxx0x-initializer-scalars.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/cxx0x-initializer-scalars.cpp b/clang/test/SemaCXX/cxx0x-initializer-scalars.cpp new file mode 100644 index 00000000000..71c4c8ecfcd --- /dev/null +++ b/clang/test/SemaCXX/cxx0x-initializer-scalars.cpp @@ -0,0 +1,34 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s + +namespace integral { + + void initialization() { + { const int a{}; static_assert(a == 0, ""); } + { const int a = {}; static_assert(a == 0, ""); } + { const int a{1}; static_assert(a == 1, ""); } + { const int a = {1}; static_assert(a == 1, ""); } + { const int a{1, 2}; } // expected-error {{excess elements}} + { const int a = {1, 2}; } // expected-error {{excess elements}} + // FIXME: Redundant warnings. + { const short a{100000}; } // expected-error {{cannot be narrowed}} expected-note {{inserting an explicit cast}} expected-warning {{changes value}} + { const short a = {100000}; } // expected-error {{cannot be narrowed}} expected-note {{inserting an explicit cast}} expected-warning {{changes value}} + } + + int direct_usage() { + int ar[10]; + (void) ar[{1}]; // expected-error {{array subscript is not an integer}} + + return {1}; + } + + void inline_init() { + (void) int{1}; + (void) new int{1}; + } + + struct A { + int i; + A() : i{1} {} + }; + +} |