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