blob: 08a65704e4cb03f59067b652d22b00fd06a4e80a [file] [log] [blame]
Chris Lattnerf47724b2010-08-17 15:55:45 +00001/* Test pragma pop_macro and push_macro directives from
2 http://msdn.microsoft.com/en-us/library/hsttss76.aspx */
3
4// pop_macro: Sets the value of the macro_name macro to the value on the top of
5// the stack for this macro.
6// #pragma pop_macro("macro_name")
7// push_macro: Saves the value of the macro_name macro on the top of the stack
8// for this macro.
9// #pragma push_macro("macro_name")
10//
11// RUN: %clang_cc1 -fms-extensions -E %s -o - | FileCheck %s
12
13#define X 1
14#define Y 2
15int pmx0 = X;
16int pmy0 = Y;
17#define Y 3
18#pragma push_macro("Y")
19#pragma push_macro("X")
20int pmx1 = X;
21#define X 2
22int pmx2 = X;
23#pragma pop_macro("X")
24int pmx3 = X;
25#pragma pop_macro("Y")
26int pmy1 = Y;
27
Chris Lattnerfc8f0e12011-04-15 05:22:18 +000028// Have a stray 'push' to show we don't crash when having imbalanced
Ted Kremeneke6a7dab2010-10-19 17:40:53 +000029// push/pop
30#pragma push_macro("Y")
31#define Y 4
32int pmy2 = Y;
33
Chris Lattnerf47724b2010-08-17 15:55:45 +000034// CHECK: int pmx0 = 1
35// CHECK: int pmy0 = 2
36// CHECK: int pmx1 = 1
37// CHECK: int pmx2 = 2
38// CHECK: int pmx3 = 1
39// CHECK: int pmy1 = 3
Ted Kremeneke6a7dab2010-10-19 17:40:53 +000040// CHECK: int pmy2 = 4
41