xref: /llvm-project/clang/test/Preprocessor/has_attribute_errors.cpp (revision 2edb89c746848c52964537268bf03e7906bf2542)
1*2edb89c7SAaron Ballman // RUN: %clang_cc1 -triple i386-unknown-unknown -Eonly -verify %s
2*2edb89c7SAaron Ballman 
3*2edb89c7SAaron Ballman // We warn users if they write an attribute like
4*2edb89c7SAaron Ballman // [[__clang__::fallthrough]] because __clang__ is a macro that expands to 1.
5*2edb89c7SAaron Ballman // Instead, we suggest users use [[_Clang::fallthrough]] in this situation.
6*2edb89c7SAaron Ballman // However, because __has_cpp_attribute (and __has_c_attribute) require
7*2edb89c7SAaron Ballman // expanding their argument tokens, __clang__ expands to 1 in the feature test
8*2edb89c7SAaron Ballman // macro as well. We don't currently give users a kind warning in this case,
9*2edb89c7SAaron Ballman // but we previously did not expand macros and so this would return 0. Now that
10*2edb89c7SAaron Ballman // we properly expand macros, users will now get an error about using incorrect
11*2edb89c7SAaron Ballman // syntax.
12*2edb89c7SAaron Ballman 
13*2edb89c7SAaron Ballman __has_cpp_attribute(__clang__::fallthrough) // expected-error {{missing ')' after <numeric_constant>}} \
14*2edb89c7SAaron Ballman                                             // expected-note {{to match this '('}} \
15*2edb89c7SAaron Ballman                                             // expected-error {{builtin feature check macro requires a parenthesized identifier}}
16*2edb89c7SAaron Ballman 
17