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 | }; |
Argyrios Kyrtzidis | 33aee39 | 2010-08-16 17:27:08 +0000 | [diff] [blame] | 24 | }; |
John McCall | 2575d88 | 2014-01-30 01:12:53 +0000 | [diff] [blame] | 25 | |
| 26 | template <class T> void foo(T); |
Charles Li | 1a88adb | 2016-04-14 23:47:07 +0000 | [diff] [blame] | 27 | typedef struct { // expected-note {{use a tag name here to establish linkage prior to definition}} |
| 28 | #if __cplusplus <= 199711L |
| 29 | // expected-note@-2 {{declared here}} |
| 30 | #endif |
| 31 | |
John McCall | 2575d88 | 2014-01-30 01:12:53 +0000 | [diff] [blame] | 32 | void test() { |
Charles Li | 1a88adb | 2016-04-14 23:47:07 +0000 | [diff] [blame] | 33 | foo(this); |
| 34 | #if __cplusplus <= 199711L |
| 35 | // expected-warning@-2 {{template argument uses unnamed type}} |
| 36 | #endif |
John McCall | 2575d88 | 2014-01-30 01:12:53 +0000 | [diff] [blame] | 37 | } |
| 38 | } A; // expected-error {{unsupported: typedef changes linkage of anonymous type, but linkage was already computed}} |