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