[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / warn-sysheader-macro.cpp
blob58d81b21d5e79a98d58e4b9639903dad620569f9
1 // RUN: %clang_cc1 -verify -fsyntax-only -Wshadow -Wold-style-cast -Wc++20-designator %s
3 // Test that macro expansions from system headers don't trigger 'syntactic'
4 // warnings that are not actionable.
6 #ifdef IS_SYSHEADER
7 #pragma clang system_header
9 #define SANITY(a) (a / 0)
11 #define SHADOW(a) __extension__({ int v = a; v; })
13 #define OLD_STYLE_CAST(a) ((int) (a))
15 struct Foo {
16 int x;
18 #define DESIGNATED_INITIALIZERS (Foo{.x = 123})
20 #else
22 #define IS_SYSHEADER
23 #include __FILE__
25 void testSanity() {
26 // Validate that the test is set up correctly
27 int i = SANITY(0); // expected-warning {{division by zero is undefined}}
30 void PR16093() {
31 // no -Wshadow in system macro expansion
32 int i = SHADOW(SHADOW(1));
35 void PR18147() {
36 // no -Wold-style-cast in system macro expansion
37 int i = OLD_STYLE_CAST(0);
40 void PR52944() {
41 // no -Wc++20-designator in system macro expansion
42 auto i = DESIGNATED_INITIALIZERS;
45 #endif