xref: /llvm-project/clang/test/Preprocessor/macro_misc.c (revision 9c4ade0623af842cda16e5c71b27fb794a3ff3db)
1 // RUN: %clang_cc1 %s -Eonly -verify
2 
3 // This should not be rejected.
4 #ifdef defined
5 #elifdef defined
6 #endif
7 // expected-warning@-2 {{use of a '#elifdef' directive is a C23 extension}}
8 
9 
10 
11 // PR3764
12 
13 // This should not produce a redefinition warning.
14 #define FUNC_LIKE(a) (a)
15 #define FUNC_LIKE(a)(a)
16 
17 // This either.
18 #define FUNC_LIKE2(a)\
19 (a)
20 #define FUNC_LIKE2(a) (a)
21 
22 // This should.
23 #define FUNC_LIKE3(a) ( a)  // expected-note {{previous definition is here}}
24 #define FUNC_LIKE3(a) (a) // expected-warning {{'FUNC_LIKE3' macro redefined}}
25 
26 // RUN: %clang_cc1 -fms-extensions -DMS_EXT %s -Eonly -verify
27 #ifndef MS_EXT
28 // This should under C99.
29 #define FUNC_LIKE4(a,b) (a+b)  // expected-note {{previous definition is here}}
30 #define FUNC_LIKE4(x,y) (x+y) // expected-warning {{'FUNC_LIKE4' macro redefined}}
31 #else
32 // This shouldn't under MS extensions.
33 #define FUNC_LIKE4(a,b) (a+b)
34 #define FUNC_LIKE4(x,y) (x+y)
35 
36 // This should.
37 #define FUNC_LIKE5(a,b) (a+b) // expected-note {{previous definition is here}}
38 #define FUNC_LIKE5(x,y) (y+x) // expected-warning {{'FUNC_LIKE5' macro redefined}}
39 #endif
40