[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Preprocessor / macro-reserved.c
blob94245c024edec272584e86558d358e10b1614b36
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
10 #undef for
11 #undef final
12 #undef __HAVE_X
13 #undef __cplusplus
14 #undef _HAVE_X
15 #undef X__Y
17 // allowlisted definitions
18 #define while while
19 #define const
20 #define static
21 #define extern
22 #define inline
24 #undef while
25 #undef const
26 #undef static
27 #undef extern
28 #undef inline
30 #define inline __inline
31 #undef inline
32 #define inline __inline__
33 #undef inline
35 #define inline inline__ // expected-warning {{keyword is hidden by macro definition}}
36 #undef inline
37 #define extern __inline // expected-warning {{keyword is hidden by macro definition}}
38 #undef extern
39 #define extern __extern // expected-warning {{keyword is hidden by macro definition}}
40 #undef extern
41 #define extern __extern__ // expected-warning {{keyword is hidden by macro definition}}
42 #undef extern
44 #define inline _inline // expected-warning {{keyword is hidden by macro definition}}
45 #undef inline
46 #define volatile // expected-warning {{keyword is hidden by macro definition}}
47 #undef volatile
49 #pragma clang diagnostic warning "-Wreserved-macro-identifier"
51 #define switch if // expected-warning {{keyword is hidden by macro definition}}
52 #define final 1
53 #define __clusplus // expected-warning {{macro name is a reserved identifier}}
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
58 #undef switch
59 #undef final
60 #undef __cplusplus // expected-warning {{macro name is a reserved identifier}}
61 #undef _HAVE_X // expected-warning {{macro name is a reserved identifier}}
62 #undef X__Y
64 int x;
66 #define _GNU_SOURCE // no-warning
67 #define __STDC_FORMAT_MACROS // no-warning