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