xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/warn-sysheader-macro.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -verify -fsyntax-only -Wshadow -Wold-style-cast %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc // Test that macro expansions from system headers don't trigger 'syntactic'
4*0a6a1f1dSLionel Sambuc // warnings that are not actionable.
5*0a6a1f1dSLionel Sambuc 
6*0a6a1f1dSLionel Sambuc #ifdef IS_SYSHEADER
7*0a6a1f1dSLionel Sambuc #pragma clang system_header
8*0a6a1f1dSLionel Sambuc 
9*0a6a1f1dSLionel Sambuc #define SANITY(a) (a / 0)
10*0a6a1f1dSLionel Sambuc 
11*0a6a1f1dSLionel Sambuc #define SHADOW(a) __extension__({ int v = a; v; })
12*0a6a1f1dSLionel Sambuc 
13*0a6a1f1dSLionel Sambuc #define OLD_STYLE_CAST(a) ((int) (a))
14*0a6a1f1dSLionel Sambuc 
15*0a6a1f1dSLionel Sambuc #else
16*0a6a1f1dSLionel Sambuc 
17*0a6a1f1dSLionel Sambuc #define IS_SYSHEADER
18*0a6a1f1dSLionel Sambuc #include __FILE__
19*0a6a1f1dSLionel Sambuc 
testSanity()20*0a6a1f1dSLionel Sambuc void testSanity() {
21*0a6a1f1dSLionel Sambuc   // Validate that the test is set up correctly
22*0a6a1f1dSLionel Sambuc   int i = SANITY(0); // expected-warning {{division by zero is undefined}}
23*0a6a1f1dSLionel Sambuc }
24*0a6a1f1dSLionel Sambuc 
PR16093()25*0a6a1f1dSLionel Sambuc void PR16093() {
26*0a6a1f1dSLionel Sambuc   // no -Wshadow in system macro expansion
27*0a6a1f1dSLionel Sambuc   int i = SHADOW(SHADOW(1));
28*0a6a1f1dSLionel Sambuc }
29*0a6a1f1dSLionel Sambuc 
PR18147()30*0a6a1f1dSLionel Sambuc void PR18147() {
31*0a6a1f1dSLionel Sambuc   // no -Wold_style_cast in system macro expansion
32*0a6a1f1dSLionel Sambuc   int i = OLD_STYLE_CAST(0);
33*0a6a1f1dSLionel Sambuc }
34*0a6a1f1dSLionel Sambuc 
35*0a6a1f1dSLionel Sambuc #endif
36