xref: /minix3/external/bsd/llvm/dist/clang/test/Lexer/gnu-flags.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu
3*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -DALL \
4*f4a2713aSLionel Sambuc // RUN:   -Wgnu-zero-variadic-macro-arguments \
5*f4a2713aSLionel Sambuc // RUN:   -Wgnu-imaginary-constant -Wgnu-binary-literal -Wgnu-zero-line-directive
6*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \
7*f4a2713aSLionel Sambuc // RUN:   -Wno-gnu-zero-variadic-macro-arguments \
8*f4a2713aSLionel Sambuc // RUN:   -Wno-gnu-imaginary-constant -Wno-gnu-binary-literal -Wno-gnu-zero-line-directive
9*f4a2713aSLionel Sambuc // Additional disabled tests:
10*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DZEROARGS -Wgnu-zero-variadic-macro-arguments
11*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DIMAGINARYCONST -Wgnu-imaginary-constant
12*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DBINARYLITERAL -Wgnu-binary-literal
13*f4a2713aSLionel Sambuc // %clang_cc1 -fsyntax-only -verify %s -DLINE0 -Wgnu-zero-line-directive
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc #if NONE
16*f4a2713aSLionel Sambuc // expected-no-diagnostics
17*f4a2713aSLionel Sambuc #endif
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc #if ALL || ZEROARGS
21*f4a2713aSLionel Sambuc // expected-warning@+9 {{must specify at least one argument for '...' parameter of variadic macro}}
22*f4a2713aSLionel Sambuc // expected-note@+4 {{macro 'efoo' defined here}}
23*f4a2713aSLionel Sambuc // expected-warning@+3 {{token pasting of ',' and __VA_ARGS__ is a GNU extension}}
24*f4a2713aSLionel Sambuc #endif
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc #define efoo(format, args...) foo(format , ##args)
27*f4a2713aSLionel Sambuc 
foo(const char * c)28*f4a2713aSLionel Sambuc void foo( const char* c )
29*f4a2713aSLionel Sambuc {
30*f4a2713aSLionel Sambuc   efoo("6");
31*f4a2713aSLionel Sambuc }
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc #if ALL || IMAGINARYCONST
35*f4a2713aSLionel Sambuc // expected-warning@+3 {{imaginary constants are a GNU extension}}
36*f4a2713aSLionel Sambuc #endif
37*f4a2713aSLionel Sambuc 
38*f4a2713aSLionel Sambuc float _Complex c = 1.if;
39*f4a2713aSLionel Sambuc 
40*f4a2713aSLionel Sambuc 
41*f4a2713aSLionel Sambuc #if ALL || BINARYLITERAL
42*f4a2713aSLionel Sambuc // expected-warning@+3 {{binary integer literals are a GNU extension}}
43*f4a2713aSLionel Sambuc #endif
44*f4a2713aSLionel Sambuc 
45*f4a2713aSLionel Sambuc int b = 0b0101;
46*f4a2713aSLionel Sambuc 
47*f4a2713aSLionel Sambuc 
48*f4a2713aSLionel Sambuc // This case is handled differently because lit has a bug whereby #line 0 is reported to be on line 4294967295
49*f4a2713aSLionel Sambuc // http://llvm.org/bugs/show_bug.cgi?id=16952
50*f4a2713aSLionel Sambuc #if ALL || LINE0
51*f4a2713aSLionel Sambuc #line 0 // expected-warning {{#line directive with zero argument is a GNU extension}}
52*f4a2713aSLionel Sambuc #else
53*f4a2713aSLionel Sambuc #line 0
54*f4a2713aSLionel Sambuc #endif
55*f4a2713aSLionel Sambuc 
56*f4a2713aSLionel Sambuc // WARNING: Do not add more tests after the #line 0 line!  Add them before the LINE0 test
57