xref: /minix3/external/bsd/llvm/dist/clang/test/PCH/macro-redef.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -emit-pch -o %t1.pch -verify
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -emit-pch -o %t2.pch -include-pch %t1.pch -verify
3*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only %s -include-pch %t2.pch -verify
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc // Test that a redefinition inside the PCH won't manifest as an ambiguous macro.
6*f4a2713aSLionel Sambuc // rdar://13016031
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc #ifndef HEADER1
9*f4a2713aSLionel Sambuc #define HEADER1
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc #define M1 0 // expected-note {{previous}}
12*f4a2713aSLionel Sambuc #define M1 1 // expected-warning {{redefined}}
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc #define M2 3
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc #elif !defined(HEADER2)
17*f4a2713aSLionel Sambuc #define HEADER2
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc #define M2 4 // expected-warning {{redefined}}
20*f4a2713aSLionel Sambuc  // expected-note@-6 {{previous}}
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc #else
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc // Use the error to verify it was parsed.
25*f4a2713aSLionel Sambuc int x = M1; // expected-note {{previous}}
26*f4a2713aSLionel Sambuc int x = M2; // expected-error {{redefinition}}
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc #endif
29