xref: /llvm-project/clang/test/Preprocessor/static_assert-already-defined.c (revision 8da090381d567d0ec555840f6b2a651d2997e4b3)
1 // RUN: %clang_cc1 -DFIRST_WAY -E -dM %s | FileCheck --strict-whitespace %s
2 // RUN: %clang_cc1 -DFIRST_WAY -fms-compatibility -E -dM %s | FileCheck --strict-whitespace %s
3 // RUN: %clang_cc1 -E -dM %s | FileCheck --strict-whitespace %s
4 // RUN: %clang_cc1 -fms-compatibility -E -dM %s | FileCheck --strict-whitespace %s
5 
6 // If the assert macro is defined in MS compatibility mode in C, we
7 // automatically inject a macro definition for static_assert. Test that the
8 // macro is not added if there is already a definition of static_assert to
9 // ensure that we don't re-define the macro in the event the Microsoft assert.h
10 // header starts to define the macro some day (or the user defined their own
11 // macro with the same name). Test that the order of the macro definitions does
12 // not matter to the behavior.
13 
14 #ifdef FIRST_WAY
15 #define static_assert 12
16 #define assert
17 #else
18 #define assert
19 #define static_assert 12
20 #endif
21 
22 CHECK: #define static_assert 12
23 
24