xref: /aosp_15_r20/external/clang/test/SemaCXX/vla.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -verify %s
2*67e74705SXin Li 
3*67e74705SXin Li // PR11925
4*67e74705SXin Li int n;
5*67e74705SXin Li int (&f())[n]; // expected-error {{function declaration cannot have variably modified type}}
6*67e74705SXin Li 
7*67e74705SXin Li namespace PR18581 {
8*67e74705SXin Li   template<typename T> struct pod {};
9*67e74705SXin Li   template<typename T> struct error {
10*67e74705SXin Li     typename T::error e; // expected-error {{cannot be used prior to '::'}}
11*67e74705SXin Li   };
12*67e74705SXin Li   struct incomplete; // expected-note {{forward declaration}}
13*67e74705SXin Li 
f(int n)14*67e74705SXin Li   void f(int n) {
15*67e74705SXin Li     pod<int> a[n];
16*67e74705SXin Li     error<int> b[n]; // expected-note {{instantiation}}
17*67e74705SXin Li     incomplete c[n]; // expected-error {{incomplete}}
18*67e74705SXin Li   }
19*67e74705SXin Li }
20*67e74705SXin Li 
pr23151(int (&)[* ])21*67e74705SXin Li void pr23151(int (&)[*]) { // expected-error {{variable length array must be bound in function definition}}
22*67e74705SXin Li }
23