Chris Lattner | f47724b | 2010-08-17 15:55:45 +0000 | [diff] [blame] | 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 |
| 15 | int pmx0 = X; |
| 16 | int pmy0 = Y; |
| 17 | #define Y 3 |
| 18 | #pragma push_macro("Y") |
| 19 | #pragma push_macro("X") |
| 20 | int pmx1 = X; |
| 21 | #define X 2 |
| 22 | int pmx2 = X; |
| 23 | #pragma pop_macro("X") |
| 24 | int pmx3 = X; |
| 25 | #pragma pop_macro("Y") |
| 26 | int pmy1 = Y; |
| 27 | |
Chris Lattner | fc8f0e1 | 2011-04-15 05:22:18 +0000 | [diff] [blame] | 28 | // Have a stray 'push' to show we don't crash when having imbalanced |
Ted Kremenek | e6a7dab | 2010-10-19 17:40:53 +0000 | [diff] [blame] | 29 | // push/pop |
| 30 | #pragma push_macro("Y") |
| 31 | #define Y 4 |
| 32 | int pmy2 = Y; |
| 33 | |
Chris Lattner | f47724b | 2010-08-17 15:55:45 +0000 | [diff] [blame] | 34 | // 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 Kremenek | e6a7dab | 2010-10-19 17:40:53 +0000 | [diff] [blame] | 40 | // CHECK: int pmy2 = 4 |
| 41 | |