xref: /minix3/external/bsd/llvm/dist/clang/test/Preprocessor/macro-reserved.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc #define for 0    // expected-warning {{keyword is hidden by macro definition}}
4*0a6a1f1dSLionel Sambuc #define final 1
5*0a6a1f1dSLionel Sambuc #define __HAVE_X 0
6*0a6a1f1dSLionel Sambuc #define __cplusplus
7*0a6a1f1dSLionel Sambuc #define _HAVE_X 0
8*0a6a1f1dSLionel Sambuc #define X__Y
9*0a6a1f1dSLionel Sambuc 
10*0a6a1f1dSLionel Sambuc #undef for
11*0a6a1f1dSLionel Sambuc #undef final
12*0a6a1f1dSLionel Sambuc #undef __HAVE_X
13*0a6a1f1dSLionel Sambuc #undef __cplusplus
14*0a6a1f1dSLionel Sambuc #undef _HAVE_X
15*0a6a1f1dSLionel Sambuc #undef X__Y
16*0a6a1f1dSLionel Sambuc 
17*0a6a1f1dSLionel Sambuc // whitelisted definitions
18*0a6a1f1dSLionel Sambuc #define while while
19*0a6a1f1dSLionel Sambuc #define const
20*0a6a1f1dSLionel Sambuc #define static
21*0a6a1f1dSLionel Sambuc #define extern
22*0a6a1f1dSLionel Sambuc #define inline
23*0a6a1f1dSLionel Sambuc 
24*0a6a1f1dSLionel Sambuc #undef while
25*0a6a1f1dSLionel Sambuc #undef const
26*0a6a1f1dSLionel Sambuc #undef static
27*0a6a1f1dSLionel Sambuc #undef extern
28*0a6a1f1dSLionel Sambuc #undef inline
29*0a6a1f1dSLionel Sambuc 
30*0a6a1f1dSLionel Sambuc #define inline __inline
31*0a6a1f1dSLionel Sambuc #undef  inline
32*0a6a1f1dSLionel Sambuc #define inline __inline__
33*0a6a1f1dSLionel Sambuc #undef  inline
34*0a6a1f1dSLionel Sambuc 
35*0a6a1f1dSLionel Sambuc #define inline inline__  // expected-warning {{keyword is hidden by macro definition}}
36*0a6a1f1dSLionel Sambuc #undef  inline
37*0a6a1f1dSLionel Sambuc #define extern __inline  // expected-warning {{keyword is hidden by macro definition}}
38*0a6a1f1dSLionel Sambuc #undef  extern
39*0a6a1f1dSLionel Sambuc #define extern __extern	 // expected-warning {{keyword is hidden by macro definition}}
40*0a6a1f1dSLionel Sambuc #undef  extern
41*0a6a1f1dSLionel Sambuc #define extern __extern__ // expected-warning {{keyword is hidden by macro definition}}
42*0a6a1f1dSLionel Sambuc #undef  extern
43*0a6a1f1dSLionel Sambuc 
44*0a6a1f1dSLionel Sambuc #define inline _inline   // expected-warning {{keyword is hidden by macro definition}}
45*0a6a1f1dSLionel Sambuc #undef  inline
46*0a6a1f1dSLionel Sambuc #define volatile   // expected-warning {{keyword is hidden by macro definition}}
47*0a6a1f1dSLionel Sambuc #undef  volatile
48*0a6a1f1dSLionel Sambuc 
49*0a6a1f1dSLionel Sambuc #pragma clang diagnostic warning "-Wreserved-id-macro"
50*0a6a1f1dSLionel Sambuc 
51*0a6a1f1dSLionel Sambuc #define switch if  // expected-warning {{keyword is hidden by macro definition}}
52*0a6a1f1dSLionel Sambuc #define final 1
53*0a6a1f1dSLionel Sambuc #define __clusplus // expected-warning {{macro name is a reserved identifier}}
54*0a6a1f1dSLionel Sambuc #define __HAVE_X 0 // expected-warning {{macro name is a reserved identifier}}
55*0a6a1f1dSLionel Sambuc #define _HAVE_X 0  // expected-warning {{macro name is a reserved identifier}}
56*0a6a1f1dSLionel Sambuc #define X__Y
57*0a6a1f1dSLionel Sambuc 
58*0a6a1f1dSLionel Sambuc #undef switch
59*0a6a1f1dSLionel Sambuc #undef final
60*0a6a1f1dSLionel Sambuc #undef __cplusplus // expected-warning {{macro name is a reserved identifier}}
61*0a6a1f1dSLionel Sambuc #undef _HAVE_X     // expected-warning {{macro name is a reserved identifier}}
62*0a6a1f1dSLionel Sambuc #undef X__Y
63*0a6a1f1dSLionel Sambuc 
64*0a6a1f1dSLionel Sambuc int x;
65