Argyrios Kyrtzidis | 33aee39 | 2010-08-16 17:27:08 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Charles Li | 1a88adb | 2016-04-14 23:47:07 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s |
| 3 | // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s |
Argyrios Kyrtzidis | 33aee39 | 2010-08-16 17:27:08 +0000 | [diff] [blame] | 4 | |
| 5 | struct S { |
Charles Li | 1a88adb | 2016-04-14 23:47:07 +0000 | [diff] [blame] | 6 | S(); |
| 7 | #if __cplusplus <= 199711L |
| 8 | // expected-note@-2 {{because type 'S' has a user-provided default constructor}} |
| 9 | #endif |
Argyrios Kyrtzidis | 33aee39 | 2010-08-16 17:27:08 +0000 | [diff] [blame] | 10 | }; |
| 11 | |
David Blaikie | 0a8e899 | 2011-10-19 22:43:29 +0000 | [diff] [blame] | 12 | struct { // expected-error {{anonymous structs and classes must be class members}} |
| 13 | }; |
| 14 | |
Argyrios Kyrtzidis | 33aee39 | 2010-08-16 17:27:08 +0000 | [diff] [blame] | 15 | struct E { |
| 16 | struct { |
Charles Li | 1a88adb | 2016-04-14 23:47:07 +0000 | [diff] [blame] | 17 | S x; |
| 18 | #if __cplusplus <= 199711L |
| 19 | // expected-error@-2 {{anonymous struct member 'x' has a non-trivial constructor}} |
| 20 | #endif |
Argyrios Kyrtzidis | 33aee39 | 2010-08-16 17:27:08 +0000 | [diff] [blame] | 21 | }; |
David Blaikie | 0a8e899 | 2011-10-19 22:43:29 +0000 | [diff] [blame] | 22 | static struct { |
| 23 | }; |
Richard Smith | 78fe171 | 2017-04-13 21:51:04 +0000 | [diff] [blame] | 24 | class { |
| 25 | int anon_priv_field; // expected-error {{anonymous struct cannot contain a private data member}} |
| 26 | }; |
Argyrios Kyrtzidis | 33aee39 | 2010-08-16 17:27:08 +0000 | [diff] [blame] | 27 | }; |
John McCall | 2575d88 | 2014-01-30 01:12:53 +0000 | [diff] [blame] | 28 | |
| 29 | template <class T> void foo(T); |
Charles Li | 1a88adb | 2016-04-14 23:47:07 +0000 | [diff] [blame] | 30 | typedef struct { // expected-note {{use a tag name here to establish linkage prior to definition}} |
| 31 | #if __cplusplus <= 199711L |
| 32 | // expected-note@-2 {{declared here}} |
| 33 | #endif |
| 34 | |
John McCall | 2575d88 | 2014-01-30 01:12:53 +0000 | [diff] [blame] | 35 | void test() { |
Charles Li | 1a88adb | 2016-04-14 23:47:07 +0000 | [diff] [blame] | 36 | foo(this); |
| 37 | #if __cplusplus <= 199711L |
| 38 | // expected-warning@-2 {{template argument uses unnamed type}} |
| 39 | #endif |
John McCall | 2575d88 | 2014-01-30 01:12:53 +0000 | [diff] [blame] | 40 | } |
| 41 | } A; // expected-error {{unsupported: typedef changes linkage of anonymous type, but linkage was already computed}} |