llvm-project
39 строк · 1.4 Кб
1// Test -D and -U interaction with a PCH when -fms-extensions is enabled.
2
3// RUN: %clang_cc1 -DFOO %S/variables.h -emit-pch -o %t1.pch
4
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
7
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
10
11// RUN: %clang_cc1 -include-pch %t1.pch -DBAR=int -pch-through-header=%S/variables.h -verify %s
12
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
16
17#include "variables.h"18
19BAR bar = 17;20#ifndef MSEXT21// expected-error@-2 {{unknown type name 'BAR'}}
22#endif23
24#ifndef FOO25# error FOO was not defined26#endif27
28#if FOO != 129# error FOO has the wrong definition30#endif31
32#if defined(MSEXT) && !defined(BAR)33# error BAR was not defined34#endif35
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
38
39// expected-warning@2 {{definition of macro 'BAR' does not match definition in precompiled header}}
40