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