summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/cxx0x-initializer-scalars.cpp34
-rw-r--r--clang/test/SemaCXX/generalized-initializers.cpp21
2 files changed, 34 insertions, 21 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} {}
+ };
+
+}
diff --git a/clang/test/SemaCXX/generalized-initializers.cpp b/clang/test/SemaCXX/generalized-initializers.cpp
index cf1b61e683c..5a420c6fc50 100644
--- a/clang/test/SemaCXX/generalized-initializers.cpp
+++ b/clang/test/SemaCXX/generalized-initializers.cpp
@@ -40,25 +40,9 @@ namespace std {
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}}
- { const short a{100000}; } // expected-error {{cannot be narrowed}}
- { const short a = {100000}; } // expected-error {{cannot be narrowed}}
- }
-
int function_call() {
void takes_int(int);
takes_int({1});
-
- int ar[10];
- (void) ar[{1}]; // expected-error {{initializer list is illegal with the built-in index operator}}
-
- return {1};
}
void inline_init() {
@@ -76,11 +60,6 @@ namespace integral {
for (int i : {1, 2, 3, 4}) {}
}
- struct A {
- int i;
- A() : i{1} {}
- };
-
}
namespace objects {
OpenPOWER on IntegriCloud