1/* 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 28// Have a stray 'push' to show we don't crash when having imbalanced 29// push/pop 30#pragma push_macro("Y") 31#define Y 4 32int pmy2 = Y; 33 34// The sequence push, define/undef, pop caused problems if macro was not 35// previously defined. 36#pragma push_macro("PREVIOUSLY_UNDEFINED1") 37#undef PREVIOUSLY_UNDEFINED1 38#pragma pop_macro("PREVIOUSLY_UNDEFINED1") 39#ifndef PREVIOUSLY_UNDEFINED1 40int Q; 41#endif 42 43#pragma push_macro("PREVIOUSLY_UNDEFINED2") 44#define PREVIOUSLY_UNDEFINED2 45#pragma pop_macro("PREVIOUSLY_UNDEFINED2") 46#ifndef PREVIOUSLY_UNDEFINED2 47int P; 48#endif 49 50// CHECK: int pmx0 = 1 51// CHECK: int pmy0 = 2 52// CHECK: int pmx1 = 1 53// CHECK: int pmx2 = 2 54// CHECK: int pmx3 = 1 55// CHECK: int pmy1 = 3 56// CHECK: int pmy2 = 4 57// CHECK: int Q; 58// CHECK: int P; 59