Richard Smith | 762bb9d | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -std=c++11 %s |
Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 2 | // RUN: cp %s %t |
Richard Smith | 762bb9d | 2011-10-13 22:29:44 +0000 | [diff] [blame] | 3 | // RUN: not %clang_cc1 -x c++ -std=c++11 -fixit %t |
| 4 | // RUN: %clang_cc1 -Wall -pedantic -x c++ -std=c++11 %t |
Douglas Gregor | 84fb9c0 | 2009-11-23 13:46:08 +0000 | [diff] [blame] | 5 | |
| 6 | /* This is a test of the various code modification hints that only |
| 7 | apply in C++0x. */ |
Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 8 | struct A { |
Douglas Gregor | 84fb9c0 | 2009-11-23 13:46:08 +0000 | [diff] [blame] | 9 | explicit operator int(); // expected-note{{conversion to integral type}} |
| 10 | }; |
| 11 | |
Nick Lewycky | ba5f6ec | 2010-04-24 01:30:46 +0000 | [diff] [blame] | 12 | void x() { |
Douglas Gregor | 84fb9c0 | 2009-11-23 13:46:08 +0000 | [diff] [blame] | 13 | switch(A()) { // expected-error{{explicit conversion to}} |
| 14 | } |
| 15 | } |
| 16 | |
Richard Smith | 162e1c1 | 2011-04-15 14:24:37 +0000 | [diff] [blame] | 17 | using ::T = void; // expected-error {{name defined in alias declaration must be an identifier}} |
| 18 | using typename U = void; // expected-error {{name defined in alias declaration must be an identifier}} |
| 19 | using typename ::V = void; // expected-error {{name defined in alias declaration must be an identifier}} |
Richard Smith | c6d990a | 2011-09-29 19:11:37 +0000 | [diff] [blame] | 20 | |
| 21 | namespace Constexpr { |
| 22 | extern constexpr int a; // expected-error {{must be a definition}} |
| 23 | // -> extern const int a; |
| 24 | |
| 25 | extern constexpr int *b; // expected-error {{must be a definition}} |
| 26 | // -> extern int *const b; |
| 27 | |
| 28 | extern constexpr int &c; // expected-error {{must be a definition}} |
| 29 | // -> extern int &b; |
| 30 | |
| 31 | extern constexpr const int d; // expected-error {{must be a definition}} |
| 32 | // -> extern const int d; |
| 33 | |
| 34 | int z; |
| 35 | constexpr int a = 0; |
| 36 | constexpr int *b = &z; |
| 37 | constexpr int &c = z; |
| 38 | constexpr int d = a; |
| 39 | |
| 40 | // FIXME: Provide FixIts for static data members too. |
| 41 | #if 0 |
| 42 | struct S { |
Richard Smith | c6d990a | 2011-09-29 19:11:37 +0000 | [diff] [blame] | 43 | static constexpr int b; // xpected-error {{requires an initializer}} |
| 44 | // -> const int b; |
| 45 | }; |
| 46 | |
Richard Smith | c6d990a | 2011-09-29 19:11:37 +0000 | [diff] [blame] | 47 | constexpr int S::b = 0; |
| 48 | #endif |
| 49 | |
| 50 | struct S { |
Richard Smith | 947be19 | 2011-09-29 23:18:34 +0000 | [diff] [blame] | 51 | static char *const p = 0; // expected-error {{requires 'constexpr' specifier}} |
Richard Smith | c6d990a | 2011-09-29 19:11:37 +0000 | [diff] [blame] | 52 | // -> constexpr static char *const p = 0; |
| 53 | }; |
| 54 | } |