mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-06 17:38:06 +00:00
c1648f2bfd
Summary: The main effect is that clang now accepts the following conforming C11 code with MSVC headers: #include <assert.h> static_assert(1, "true"); This is a non-conforming extension (the keyword is outside the implementer's namespace), so it is placed under -fms-compatibility instead of -fms-extensions like most MSVC-specific keyword extensions. Normally, in C11, the compiler is supposed to provide the _Static_assert keyword, and assert.h should define static_assert to _Static_assert. However, that is not what MSVC does, and MSVC doesn't even provide _Static_assert. This also has the less important side effect of enabling static_assert in C++98 mode with -fms-compatibility. It's exceptionally difficult to use modern MSVC headers without C++14 even, so this is relatively unimportant. Fixes PR26672 Patch by Andrey Bokhanko! Reviewers: rsmith, thakis Subscribers: cfe-commits, STL_MSFT Differential Revision: https://reviews.llvm.org/D17444 llvm-svn: 354162
55 lines
1.6 KiB
C
55 lines
1.6 KiB
C
// RUN: %clang_cc1 -std=c99 -E %s -o - | FileCheck --check-prefix=CHECK-NONE %s
|
|
|
|
// RUN: %clang_cc1 -std=gnu89 -E %s -o - \
|
|
// RUN: | FileCheck --check-prefix=CHECK-GNU-KEYWORDS %s
|
|
// RUN: %clang_cc1 -std=c99 -fgnu-keywords -E %s -o - \
|
|
// RUN: | FileCheck --check-prefix=CHECK-GNU-KEYWORDS %s
|
|
// RUN: %clang_cc1 -std=gnu89 -fno-gnu-keywords -E %s -o - \
|
|
// RUN: | FileCheck --check-prefix=CHECK-NONE %s
|
|
|
|
// RUN: %clang_cc1 -std=c99 -fms-extensions -fms-compatibility -E %s -o - \
|
|
// RUN: | FileCheck --check-prefix=CHECK-MS-KEYWORDS %s
|
|
// RUN: %clang_cc1 -std=c99 -fdeclspec -E %s -o - \
|
|
// RUN: | FileCheck --check-prefix=CHECK-DECLSPEC-KEYWORD %s
|
|
// RUN: %clang_cc1 -std=c99 -fms-extensions -fno-declspec -E %s -o - \
|
|
// RUN: | FileCheck --check-prefix=CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC %s
|
|
|
|
void f() {
|
|
// CHECK-NONE: int asm
|
|
// CHECK-GNU-KEYWORDS: asm ("ret" : :)
|
|
#if __is_identifier(asm)
|
|
int asm;
|
|
#else
|
|
asm ("ret" : :);
|
|
#endif
|
|
}
|
|
|
|
// CHECK-NONE: no_ms_wchar
|
|
// CHECK-MS-KEYWORDS: has_ms_wchar
|
|
// CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC: has_ms_wchar
|
|
#if __is_identifier(__wchar_t)
|
|
void no_ms_wchar();
|
|
#else
|
|
void has_ms_wchar();
|
|
#endif
|
|
|
|
// CHECK-NONE: no_declspec
|
|
// CHECK-MS-KEYWORDS: has_declspec
|
|
// CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC: no_declspec
|
|
// CHECK-DECLSPEC-KEYWORD: has_declspec
|
|
#if __is_identifier(__declspec)
|
|
void no_declspec();
|
|
#else
|
|
void has_declspec();
|
|
#endif
|
|
|
|
// CHECK-NONE: no_static_assert
|
|
// CHECK-GNU-KEYWORDS: no_static_assert
|
|
// CHECK-MS-KEYWORDS: has_static_assert
|
|
// CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC: no_static_assert
|
|
#if __is_identifier(static_assert)
|
|
void no_static_assert();
|
|
#else
|
|
void has_static_assert();
|
|
#endif
|