blob: 41fc2193891c9b82cfe8f6d51b0ca6fa120e9cb1 [file] [log] [blame]
Richard Smith762bb9d2011-10-13 22:29:44 +00001// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
Sebastian Redl6df65482011-09-24 17:48:25 +00002
3namespace integral {
4
5 void initialization() {
6 { const int a{}; static_assert(a == 0, ""); }
7 { const int a = {}; static_assert(a == 0, ""); }
8 { const int a{1}; static_assert(a == 1, ""); }
9 { const int a = {1}; static_assert(a == 1, ""); }
10 { const int a{1, 2}; } // expected-error {{excess elements}}
11 { const int a = {1, 2}; } // expected-error {{excess elements}}
12 // FIXME: Redundant warnings.
13 { const short a{100000}; } // expected-error {{cannot be narrowed}} expected-note {{inserting an explicit cast}} expected-warning {{changes value}}
14 { const short a = {100000}; } // expected-error {{cannot be narrowed}} expected-note {{inserting an explicit cast}} expected-warning {{changes value}}
15 }
16
17 int direct_usage() {
18 int ar[10];
19 (void) ar[{1}]; // expected-error {{array subscript is not an integer}}
20
21 return {1};
22 }
23
24 void inline_init() {
25 (void) int{1};
26 (void) new int{1};
27 }
28
29 struct A {
30 int i;
31 A() : i{1} {}
32 };
33
34}