Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Preprocessor / macro-reserved.c
blob6026a9f60730e764decf63afa4b5215bedceb35a
1 // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
3 #define for 0 // expected-warning {{keyword is hidden by macro definition}}
4 #define final 1
5 #define __HAVE_X 0
6 #define __cplusplus
7 #define _HAVE_X 0
8 #define X__Y
9 #define __STDC__ 1 // expected-warning {{redefining builtin macro}}
10 #define __clang__ 1
12 #undef for
13 #undef final
14 #undef __HAVE_X
15 #undef __cplusplus
16 #undef _HAVE_X
17 #undef X__Y
18 #undef __STDC_HOSTED__ // expected-warning {{undefining builtin macro}}
19 #undef __INT32_TYPE__
20 #undef __UINT32_TYPE__
21 #undef __UINTPTR_TYPE__
22 #undef __UINT64_TYPE__
23 #undef __INT64_TYPE__
24 #undef __OPTIMIZE__
26 // allowlisted definitions
27 #define while while
28 #define const
29 #define static
30 #define extern
31 #define inline
33 #undef while
34 #undef const
35 #undef static
36 #undef extern
37 #undef inline
39 #define inline __inline
40 #undef inline
41 #define inline __inline__
42 #undef inline
44 #define inline inline__ // expected-warning {{keyword is hidden by macro definition}}
45 #undef inline
46 #define extern __inline // expected-warning {{keyword is hidden by macro definition}}
47 #undef extern
48 #define extern __extern // expected-warning {{keyword is hidden by macro definition}}
49 #undef extern
50 #define extern __extern__ // expected-warning {{keyword is hidden by macro definition}}
51 #undef extern
53 #define inline _inline // expected-warning {{keyword is hidden by macro definition}}
54 #undef inline
55 #define volatile // expected-warning {{keyword is hidden by macro definition}}
56 #undef volatile
58 #pragma clang diagnostic warning "-Wreserved-macro-identifier"
60 #define switch if // expected-warning {{keyword is hidden by macro definition}}
61 #define final 1
62 #define __clusplus // expected-warning {{macro name is a reserved identifier}}
63 #define __HAVE_X 0 // expected-warning {{macro name is a reserved identifier}}
64 #define _HAVE_X 0 // expected-warning {{macro name is a reserved identifier}}
65 #define X__Y
67 #undef switch
68 #undef final
69 #undef __cplusplus // expected-warning {{macro name is a reserved identifier}}
70 #undef _HAVE_X // expected-warning {{macro name is a reserved identifier}}
71 #undef X__Y
73 int x;
75 #define _GNU_SOURCE // no-warning
76 #define __STDC_FORMAT_MACROS // no-warning