xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/anonymous-struct.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc struct S {
4f4a2713aSLionel Sambuc   S();  // expected-note {{because type 'S' has a user-provided default constructor}}
5f4a2713aSLionel Sambuc };
6f4a2713aSLionel Sambuc 
7f4a2713aSLionel Sambuc struct { // expected-error {{anonymous structs and classes must be class members}}
8f4a2713aSLionel Sambuc };
9f4a2713aSLionel Sambuc 
10f4a2713aSLionel Sambuc struct E {
11f4a2713aSLionel Sambuc   struct {
12f4a2713aSLionel Sambuc     S x;  // expected-error {{anonymous struct member 'x' has a non-trivial constructor}}
13f4a2713aSLionel Sambuc   };
14f4a2713aSLionel Sambuc   static struct {
15f4a2713aSLionel Sambuc   };
16f4a2713aSLionel Sambuc };
17*0a6a1f1dSLionel Sambuc 
18*0a6a1f1dSLionel Sambuc template <class T> void foo(T);
19*0a6a1f1dSLionel Sambuc typedef struct { // expected-note {{use a tag name here to establish linkage prior to definition}} expected-note {{declared here}}
test__anon6fed09f9040820*0a6a1f1dSLionel Sambuc   void test() {
21*0a6a1f1dSLionel Sambuc     foo(this); // expected-warning {{template argument uses unnamed type}}
22*0a6a1f1dSLionel Sambuc   }
23*0a6a1f1dSLionel Sambuc } A; // expected-error {{unsupported: typedef changes linkage of anonymous type, but linkage was already computed}}
24