Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Preprocessor / macro-reserved.cpp
blob53bb3634bac4c2c46ac8bcb2712d799eb1701d82
1 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++98 %s
3 #define for 0 // expected-warning {{keyword is hidden by macro definition}}
4 #define final 1
5 #define __HAVE_X 0
6 #define _HAVE_X 0
7 #define X__Y
9 #undef for
10 #undef final
11 #undef __HAVE_X
12 #undef _HAVE_X
13 #undef X__Y
15 #undef __cplusplus // expected-warning {{undefining builtin macro}}
16 #define __cplusplus
18 // allowlisted definitions
19 #define while while
20 #define const
21 #define static
22 #define extern
23 #define inline
25 #undef while
26 #undef const
27 #undef static
28 #undef extern
29 #undef inline
31 #define inline __inline
32 #undef inline
33 #define inline __inline__
34 #undef inline
36 #define inline inline__ // expected-warning {{keyword is hidden by macro definition}}
37 #undef inline
38 #define extern __inline // expected-warning {{keyword is hidden by macro definition}}
39 #undef extern
40 #define extern __extern // expected-warning {{keyword is hidden by macro definition}}
41 #undef extern
42 #define extern __extern__ // expected-warning {{keyword is hidden by macro definition}}
43 #undef extern
45 #define inline _inline // expected-warning {{keyword is hidden by macro definition}}
46 #undef inline
47 #define volatile // expected-warning {{keyword is hidden by macro definition}}
48 #undef volatile
50 #pragma clang diagnostic warning "-Wreserved-macro-identifier"
52 #define switch if // expected-warning {{keyword is hidden by macro definition}}
53 #define final 1
54 #define __HAVE_X 0 // expected-warning {{macro name is a reserved identifier}}
55 #define _HAVE_X 0 // expected-warning {{macro name is a reserved identifier}}
56 #define X__Y // expected-warning {{macro name is a reserved identifier}}
58 #undef __cplusplus // expected-warning {{macro name is a reserved identifier}}
59 #undef _HAVE_X // expected-warning {{macro name is a reserved identifier}}
60 #undef X__Y // expected-warning {{macro name is a reserved identifier}}
62 int x;