Sebastian Redl | 6df6548 | 2011-09-24 17:48:25 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s |
| 2 | |
| 3 | namespace 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 | } |