blob: 2addad4696ea0b9b1cf96a0458cfaab912fa8ffb [file] [log] [blame]
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +00001// RUN: %clang_cc1 -verify -std=c++0x %s
2// RUN: cp %s %t
Richard Smithc6d990a2011-09-29 19:11:37 +00003// RUN: not %clang_cc1 -x c++ -std=c++0x -Werror -fixit %t
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +00004// RUN: %clang_cc1 -Wall -pedantic -x c++ -std=c++0x %t
Douglas Gregor84fb9c02009-11-23 13:46:08 +00005
6/* This is a test of the various code modification hints that only
7 apply in C++0x. */
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +00008struct A {
Douglas Gregor84fb9c02009-11-23 13:46:08 +00009 explicit operator int(); // expected-note{{conversion to integral type}}
10};
11
Nick Lewyckyba5f6ec2010-04-24 01:30:46 +000012void x() {
Douglas Gregor84fb9c02009-11-23 13:46:08 +000013 switch(A()) { // expected-error{{explicit conversion to}}
14 }
15}
16
Richard Smith162e1c12011-04-15 14:24:37 +000017using ::T = void; // expected-error {{name defined in alias declaration must be an identifier}}
18using typename U = void; // expected-error {{name defined in alias declaration must be an identifier}}
19using typename ::V = void; // expected-error {{name defined in alias declaration must be an identifier}}
Richard Smithc6d990a2011-09-29 19:11:37 +000020
21namespace 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 {
43 static constexpr int a = 0;
44
45 static constexpr int b; // xpected-error {{requires an initializer}}
46 // -> const int b;
47 };
48
49 constexpr int S::a; // xpected-error {{requires an initializer}}
50 // -> const int S::a;
51
52 constexpr int S::b = 0;
53#endif
54
55 struct S {
56 static const double d = 0.0; // expected-warning {{accepted as an extension}}
57 // -> constexpr static const double d = 0.0;
58 static char *const p = 0; // expected-warning {{accepted as an extension}}
59 // -> constexpr static char *const p = 0;
60 };
61}