xref: /llvm-project/clang/test/C/C11/n1460.c (revision 32d441bfb4f302e02736dc922b0388c7594fd90e)
1 // RUN: %clang_cc1 -verify -Wno-vla %s
2 
3 /* WG14 N1460: Yes
4  * Subsetting the standard
5  */
6 
7 // If we claim to not support the feature then we expect diagnostics when
8 // using that feature. Otherwise, we expect no diagnostics.
9 #ifdef __STDC_NO_COMPLEX__
10   // PS4/PS5 set this to indicate no <complex.h> but still support the
11   // _Complex syntax.
12   #ifdef __SCE__
13     #define HAS_COMPLEX
14   #else
15     // We do not have any other targets which do not support complex, so we
16     // don't expect to get into this block.
17     #error "it's unexpected that we don't support complex"
18   #endif
19   float _Complex fc;
20   double _Complex dc;
21   long double _Complex ldc;
22 #else
23   #define HAS_COMPLEX
24   float _Complex fc;
25   double _Complex dc;
26   long double _Complex ldc;
27 #endif
28 
29 #ifdef __STDC_NO_VLA__
30   // We do not have any targets which do not support VLAs, so we don't expect
31   // to get into this block.
32   #error "it's unexpected that we don't support VLAs"
33 
func(int n,int m[n])34   void func(int n, int m[n]) {
35     int array[n];
36   }
37 #else
38   #define HAS_VLA
func(int n,int m[n])39   void func(int n, int m[n]) {
40     int array[n];
41   }
42 #endif
43 
44 // NB: it's not possible to test for __STDC_NO_THREADS__ because that is
45 // specifically about whether <threads.h> exists and is supported, which is
46 // outside the control of the compiler. It does not cover use of thread_local.
47 
48 #if defined(HAS_COMPLEX) && defined(HAS_VLA)
49 // If we support all these optional features, we don't expect any other
50 // diagnostics to have fired.
51 
52 // expected-no-diagnostics
53 #endif
54 
55