46 lines · cpp
1// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow -Wold-style-cast -Wc++20-designator %s2 3// Test that macro expansions from system headers don't trigger 'syntactic'4// warnings that are not actionable.5 6#ifdef IS_SYSHEADER7#pragma clang system_header8 9#define SANITY(a) (a / 0)10 11#define SHADOW(a) __extension__({ int v = a; v; })12 13#define OLD_STYLE_CAST(a) ((int) (a))14 15struct Foo {16 int x;17};18#define DESIGNATED_INITIALIZERS (Foo{.x = 123})19 20#else21 22#define IS_SYSHEADER23#include __FILE__24 25void testSanity() {26 // Validate that the test is set up correctly27 int i = SANITY(0); // expected-warning {{division by zero is undefined}}28}29 30void PR16093() {31 // no -Wshadow in system macro expansion32 int i = SHADOW(SHADOW(1));33}34 35void PR18147() {36 // no -Wold-style-cast in system macro expansion37 int i = OLD_STYLE_CAST(0);38}39 40void PR52944() {41 // no -Wc++20-designator in system macro expansion42 auto i = DESIGNATED_INITIALIZERS;43}44 45#endif46