brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 1f2e884 Raw
46 lines · c
1// RUN: %clang_cc1 -fsyntax-only %s -verify2#ifndef __has_warning3#error Should have __has_warning4#endif5 6#if __has_warning("not valid") // expected-warning {{__has_warning expected option name}}7#endif8 9// expected-warning@+2 {{Should have -Wparentheses}}10#if __has_warning("-Wparentheses")11#warning Should have -Wparentheses12#endif13 14// expected-error@+2 {{expected string literal in '__has_warning'}}15// expected-error@+1 {{missing ')'}} expected-note@+1 {{match}}16#if __has_warning(-Wfoo)17#endif18 19// expected-warning@+3 {{Not a valid warning flag}}20#if __has_warning("-Wnot-a-valid-warning-flag-at-all")21#else22#warning Not a valid warning flag23#endif24 25// expected-error@+1 {{missing '(' after '__has_warning'}}26#if __has_warning "not valid"27#endif28 29// Macro expansion does not occur in the parameter to __has_warning30// (as is also expected behaviour for ordinary macros), so the31// following should not expand:32 33#define MY_ALIAS "-Wparentheses"34 35// expected-error@+1 {{expected}}36#if __has_warning(MY_ALIAS)37#error Alias expansion not allowed38#endif39 40// But deferring should expand:41#define HAS_WARNING(X) __has_warning(X)42 43#if !HAS_WARNING(MY_ALIAS)44#error Expansion should have occurred45#endif46