1*f4a2713aSLionel Sambuc /* Test pragma pop_macro and push_macro directives from 2*f4a2713aSLionel Sambuc http://msdn.microsoft.com/en-us/library/hsttss76.aspx */ 3*f4a2713aSLionel Sambuc 4*f4a2713aSLionel Sambuc // pop_macro: Sets the value of the macro_name macro to the value on the top of 5*f4a2713aSLionel Sambuc // the stack for this macro. 6*f4a2713aSLionel Sambuc // #pragma pop_macro("macro_name") 7*f4a2713aSLionel Sambuc // push_macro: Saves the value of the macro_name macro on the top of the stack 8*f4a2713aSLionel Sambuc // for this macro. 9*f4a2713aSLionel Sambuc // #pragma push_macro("macro_name") 10*f4a2713aSLionel Sambuc // 11*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fms-extensions -E %s -o - | FileCheck %s 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc #define X 1 14*f4a2713aSLionel Sambuc #define Y 2 15*f4a2713aSLionel Sambuc int pmx0 = X; 16*f4a2713aSLionel Sambuc int pmy0 = Y; 17*f4a2713aSLionel Sambuc #define Y 3 18*f4a2713aSLionel Sambuc #pragma push_macro("Y") 19*f4a2713aSLionel Sambuc #pragma push_macro("X") 20*f4a2713aSLionel Sambuc int pmx1 = X; 21*f4a2713aSLionel Sambuc #define X 2 22*f4a2713aSLionel Sambuc int pmx2 = X; 23*f4a2713aSLionel Sambuc #pragma pop_macro("X") 24*f4a2713aSLionel Sambuc int pmx3 = X; 25*f4a2713aSLionel Sambuc #pragma pop_macro("Y") 26*f4a2713aSLionel Sambuc int pmy1 = Y; 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc // Have a stray 'push' to show we don't crash when having imbalanced 29*f4a2713aSLionel Sambuc // push/pop 30*f4a2713aSLionel Sambuc #pragma push_macro("Y") 31*f4a2713aSLionel Sambuc #define Y 4 32*f4a2713aSLionel Sambuc int pmy2 = Y; 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambuc // The sequence push, define/undef, pop caused problems if macro was not 35*f4a2713aSLionel Sambuc // previously defined. 36*f4a2713aSLionel Sambuc #pragma push_macro("PREVIOUSLY_UNDEFINED1") 37*f4a2713aSLionel Sambuc #undef PREVIOUSLY_UNDEFINED1 38*f4a2713aSLionel Sambuc #pragma pop_macro("PREVIOUSLY_UNDEFINED1") 39*f4a2713aSLionel Sambuc #ifndef PREVIOUSLY_UNDEFINED1 40*f4a2713aSLionel Sambuc int Q; 41*f4a2713aSLionel Sambuc #endif 42*f4a2713aSLionel Sambuc 43*f4a2713aSLionel Sambuc #pragma push_macro("PREVIOUSLY_UNDEFINED2") 44*f4a2713aSLionel Sambuc #define PREVIOUSLY_UNDEFINED2 45*f4a2713aSLionel Sambuc #pragma pop_macro("PREVIOUSLY_UNDEFINED2") 46*f4a2713aSLionel Sambuc #ifndef PREVIOUSLY_UNDEFINED2 47*f4a2713aSLionel Sambuc int P; 48*f4a2713aSLionel Sambuc #endif 49*f4a2713aSLionel Sambuc 50*f4a2713aSLionel Sambuc // CHECK: int pmx0 = 1 51*f4a2713aSLionel Sambuc // CHECK: int pmy0 = 2 52*f4a2713aSLionel Sambuc // CHECK: int pmx1 = 1 53*f4a2713aSLionel Sambuc // CHECK: int pmx2 = 2 54*f4a2713aSLionel Sambuc // CHECK: int pmx3 = 1 55*f4a2713aSLionel Sambuc // CHECK: int pmy1 = 3 56*f4a2713aSLionel Sambuc // CHECK: int pmy2 = 4 57*f4a2713aSLionel Sambuc // CHECK: int Q; 58*f4a2713aSLionel Sambuc // CHECK: int P; 59