blob: bb7e6eb92da308f1fac4cf8460ea21e6a628fd9d [file] [log] [blame]
Argyrios Kyrtzidis33aee392010-08-16 17:27:08 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Charles Li1a88adb2016-04-14 23:47:07 +00002// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
Argyrios Kyrtzidis33aee392010-08-16 17:27:08 +00004
5struct S {
Charles Li1a88adb2016-04-14 23:47:07 +00006 S();
7#if __cplusplus <= 199711L
8 // expected-note@-2 {{because type 'S' has a user-provided default constructor}}
9#endif
Argyrios Kyrtzidis33aee392010-08-16 17:27:08 +000010};
11
David Blaikie0a8e8992011-10-19 22:43:29 +000012struct { // expected-error {{anonymous structs and classes must be class members}}
13};
14
Argyrios Kyrtzidis33aee392010-08-16 17:27:08 +000015struct E {
16 struct {
Charles Li1a88adb2016-04-14 23:47:07 +000017 S x;
18#if __cplusplus <= 199711L
19 // expected-error@-2 {{anonymous struct member 'x' has a non-trivial constructor}}
20#endif
Argyrios Kyrtzidis33aee392010-08-16 17:27:08 +000021 };
David Blaikie0a8e8992011-10-19 22:43:29 +000022 static struct {
23 };
Richard Smith78fe1712017-04-13 21:51:04 +000024 class {
25 int anon_priv_field; // expected-error {{anonymous struct cannot contain a private data member}}
26 };
Argyrios Kyrtzidis33aee392010-08-16 17:27:08 +000027};
John McCall2575d882014-01-30 01:12:53 +000028
29template <class T> void foo(T);
Charles Li1a88adb2016-04-14 23:47:07 +000030typedef 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 McCall2575d882014-01-30 01:12:53 +000035 void test() {
Charles Li1a88adb2016-04-14 23:47:07 +000036 foo(this);
37#if __cplusplus <= 199711L
38 // expected-warning@-2 {{template argument uses unnamed type}}
39#endif
John McCall2575d882014-01-30 01:12:53 +000040 }
41} A; // expected-error {{unsupported: typedef changes linkage of anonymous type, but linkage was already computed}}