xref: /llvm-project/clang/test/C/drs/dr491.c (revision 7fc57d7c97c64b64ef865d71343867ab30cfcf15)
1 /* RUN: %clang_cc1 -std=c89 -verify -Wreserved-macro-identifier %s
2    RUN: %clang_cc1 -std=c99 -verify -Wreserved-macro-identifier %s
3    RUN: %clang_cc1 -std=c11 -verify -Wreserved-macro-identifier %s
4    RUN: %clang_cc1 -std=c17 -verify -Wreserved-macro-identifier %s
5    RUN: %clang_cc1 -std=c2x -verify -Wreserved-macro-identifier %s
6  */
7 
8 /* WG14 DR491: partial
9  * Concern with Keywords that Match Reserved Identifiers
10  *
11  * Claiming this as partial because we do not reject code using a reserved
12  * identifier, but our reserved identifier code incorrectly identifies some
13  * keywords as reserved identifiers for macro names, but not others.
14  */
15 
16 #define const const
17 #define int int
18 #define restrict restrict
19 
20 /* FIXME: none of these should diagnose the macro name as a reserved
21  * identifier per C2x 6.4.2p7 (similar wording existed in earlier standard
22  * versions).
23  */
24 #define _Static_assert _Static_assert  /* expected-warning {{macro name is a reserved identifier}} */
25 #define _Alignof(x) _Alignof(x)        /* expected-warning {{macro name is a reserved identifier}} */
26 #define _Bool _Bool                    /* expected-warning {{macro name is a reserved identifier}} */
27 #define __has_c_attribute __has_c_attribute /* expected-warning {{macro name is a reserved identifier}}
28                                                expected-warning {{redefining builtin macro}}
29                                              */
30 #define __restrict__ __restrict__      /* expected-warning {{macro name is a reserved identifier}} */
31