mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-27 14:16:08 +00:00

Our diagnostics relating to static assertions were a bit confused. For instance, when in MS compatibility mode in C (where we accept static_assert even without including <assert.h>), we would fail to warn the user that they were using the wrong spelling (even in pedantic mode), we were missing a compatibility warning about using _Static_assert in earlier standards modes, diagnostics for the optional message were not reflected in C as they were in C++, etc.
24 lines
951 B
C
24 lines
951 B
C
// RUN: %clang_cc1 -DFIRST_WAY -E -dM %s | FileCheck --strict-whitespace %s
|
|
// RUN: %clang_cc1 -DFIRST_WAY -fms-compatibility -E -dM %s | FileCheck --strict-whitespace %s
|
|
// RUN: %clang_cc1 -E -dM %s | FileCheck --strict-whitespace %s
|
|
// RUN: %clang_cc1 -fms-compatibility -E -dM %s | FileCheck --strict-whitespace %s
|
|
|
|
// If the assert macro is defined in MS compatibility mode in C, we
|
|
// automatically inject a macro definition for static_assert. Test that the
|
|
// macro is not added if there is already a definition of static_assert to
|
|
// ensure that we don't re-define the macro in the event the Microsoft assert.h
|
|
// header starts to define the macro some day (or the user defined their own
|
|
// macro with the same name). Test that the order of the macro definitions does
|
|
// not matter to the behavior.
|
|
|
|
#ifdef FIRST_WAY
|
|
#define static_assert 12
|
|
#define assert
|
|
#else
|
|
#define assert
|
|
#define static_assert 12
|
|
#endif
|
|
|
|
CHECK: #define static_assert 12
|
|
|