[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / PCH / ms-pch-macro.c
blob3a8052eb322e91cdabdeee6879dc94ba5c0061b5
1 // Test -D and -U interaction with a PCH when -fms-extensions is enabled.
3 // RUN: %clang_cc1 -DFOO %S/variables.h -emit-pch -o %t1.pch
5 // RUN: not %clang_cc1 -DFOO=blah -DBAR=int -include-pch %t1.pch -pch-through-header=%S/variables.h %s 2> %t.err
6 // RUN: FileCheck -check-prefix=CHECK-FOO %s < %t.err
8 // RUN: not %clang_cc1 -UFOO -DBAR=int -include-pch %t1.pch %s -pch-through-header=%S/variables.h 2> %t.err
9 // RUN: FileCheck -check-prefix=CHECK-NOFOO %s < %t.err
11 // RUN: %clang_cc1 -include-pch %t1.pch -DBAR=int -pch-through-header=%S/variables.h -verify %s
13 // Enabling MS extensions should allow us to add BAR definitions.
14 // RUN: %clang_cc1 -DMSEXT -fms-extensions -DFOO %S/variables.h -emit-pch -o %t1.pch
15 // RUN: %clang_cc1 -DMSEXT -fms-extensions -include-pch %t1.pch -DBAR=int -pch-through-header=%S/variables.h -verify %s
17 #include "variables.h"
19 BAR bar = 17;
20 #ifndef MSEXT
21 // expected-error@-2 {{unknown type name 'BAR'}}
22 #endif
24 #ifndef FOO
25 # error FOO was not defined
26 #endif
28 #if FOO != 1
29 # error FOO has the wrong definition
30 #endif
32 #if defined(MSEXT) && !defined(BAR)
33 # error BAR was not defined
34 #endif
36 // CHECK-FOO: definition of macro 'FOO' differs between the precompiled header ('1') and the command line ('blah')
37 // CHECK-NOFOO: macro 'FOO' was defined in the precompiled header but undef'd on the command line
39 // expected-warning@1 {{definition of macro 'BAR' does not match definition in precompiled header}}