xref: /llvm-project/clang/test/Parser/using-if-exists-attr.cpp (revision 369c64839946d89cf5697550b6feeea031b2f270)
1*369c6483SErik Pilkington // RUN: %clang_cc1 -std=c++20 -fsyntax-only %s -pedantic -verify
2*369c6483SErik Pilkington 
3*369c6483SErik Pilkington #define UIE __attribute__((using_if_exists))
4*369c6483SErik Pilkington 
5*369c6483SErik Pilkington namespace NS {
6*369c6483SErik Pilkington typedef int x;
7*369c6483SErik Pilkington }
8*369c6483SErik Pilkington 
9*369c6483SErik Pilkington using NS::x __attribute__((using_if_exists));
10*369c6483SErik Pilkington 
11*369c6483SErik Pilkington using NS::x [[clang::using_if_exists]]; // expected-warning{{ISO C++ does not allow an attribute list to appear here}}
12*369c6483SErik Pilkington 
13*369c6483SErik Pilkington [[clang::using_if_exists]] // expected-warning{{ISO C++ does not allow an attribute list to appear here}}
14*369c6483SErik Pilkington using NS::not_there,
15*369c6483SErik Pilkington     NS::not_there2;
16*369c6483SErik Pilkington 
17*369c6483SErik Pilkington using NS::not_there3,                          // expected-error {{no member named 'not_there3' in namespace 'NS'}}
18*369c6483SErik Pilkington     NS::not_there4 [[clang::using_if_exists]]; // expected-warning{{C++ does not allow an attribute list to appear here}}
19*369c6483SErik Pilkington 
20*369c6483SErik Pilkington [[clang::using_if_exists]] using NS::not_there5 [[clang::using_if_exists]]; // expected-warning 2 {{ISO C++ does not allow}}
21*369c6483SErik Pilkington 
22*369c6483SErik Pilkington struct Base {};
23*369c6483SErik Pilkington struct Derived : Base {
24*369c6483SErik Pilkington   [[clang::using_if_exists]] using Base::x;          // expected-warning {{ISO C++ does not allow an attribute list to appear here}}
25*369c6483SErik Pilkington   using Base::y [[clang::using_if_exists]];          // expected-warning {{ISO C++ does not allow an attribute list to appear here}}
26*369c6483SErik Pilkington   [[clang::using_if_exists]] using Base::z, Base::q; // expected-warning {{C++ does not allow an attribute list to appear here}}
27*369c6483SErik Pilkington };
28