69 lines · c
1// RUN: %clang_cc1 -fsyntax-only -verify -Wc++-hidden-decl %s2// RUN: %clang_cc1 -fsyntax-only -verify -Wc++-compat %s3// RUN: %clang_cc1 -fsyntax-only -verify=good %s4// RUN: %clang_cc1 -fsyntax-only -verify=cxx -x c++ -std=c++2c %s5// good-no-diagnostics6 7struct A {8 struct B { // #b-decl9 int x;10 } bs;11 enum E { // #e-decl12 One13 } es;14 int y;15};16 17struct C {18 struct D {19 struct F { // #f-decl20 int x;21 } f;22 } d;23};24 25struct B b; // expected-warning {{struct defined within a struct or union is not visible in C++}} \26 expected-note@#b-decl {{declared here}} \27 cxx-error {{variable has incomplete type 'struct B'}} \28 cxx-note 3 {{forward declaration of 'B'}}29enum E e; // expected-warning {{enum defined within a struct or union is not visible in C++}} \30 expected-note@#e-decl {{declared here}} \31 cxx-error {{ISO C++ forbids forward references to 'enum' types}} \32 cxx-error {{variable has incomplete type 'enum E'}} \33 cxx-note 3 {{forward declaration of 'E'}}34struct F f; // expected-warning {{struct defined within a struct or union is not visible in C++}} \35 expected-note@#f-decl {{declared here}} \36 cxx-error {{variable has incomplete type 'struct F'}} \37 cxx-note {{forward declaration of 'F'}}38 39void func(struct B b); // expected-warning {{struct defined within a struct or union is not visible in C++}} \40 expected-note@#b-decl {{declared here}}41void other_func(enum E e) { // expected-warning {{enum defined within a struct or union is not visible in C++}} \42 expected-note@#e-decl {{declared here}} \43 cxx-error {{variable has incomplete type 'enum E'}}44 struct B b; // expected-warning {{struct defined within a struct or union is not visible in C++}} \45 expected-note@#b-decl {{declared here}} \46 cxx-error {{variable has incomplete type 'struct B'}}47}48 49struct X {50 struct B b; // expected-warning {{struct defined within a struct or union is not visible in C++}} \51 expected-note@#b-decl {{declared here}} \52 cxx-error {{field has incomplete type 'struct B'}}53 enum E e; // expected-warning {{enum defined within a struct or union is not visible in C++}} \54 expected-note@#e-decl {{declared here}} \55 cxx-error {{field has incomplete type 'enum E'}}56};57 58struct Y {59 struct Z1 {60 int x;61 } zs;62 63 struct Z2 {64 // This is fine, it is still valid C++.65 struct Z1 inner_zs;66 } more_zs;67};68 69