[FMV][GlobalOpt] Enable static resolution of non-FMV callers. (#124314)
[llvm-project.git] / clang / test / CXX / dcl.dcl / basic.namespace / namespace.udecl / p3.cpp
blob3351666525374eb55216984e00b71f7b59a567a0
1 // RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
3 // RUN: %clang_cc1 -fsyntax-only -verify %s
5 struct B {
6 void f(char);
7 void g(char);
8 enum E { e };
9 union { int x; };
11 enum class EC { ec }; // expected-warning 0-1 {{C++11}}
13 void f2(char);
14 void g2(char);
15 enum E2 { e2 };
16 union { int x2; };
19 class C {
20 public:
21 int g();
24 struct D : B {};
26 class D2 : public B {
27 using B::f;
28 using B::E;
29 using B::e;
30 using B::x;
31 using C::g; // expected-error{{using declaration refers into 'C::', which is not a base class of 'D2'}}
33 // These are valid in C++98 but not in C++11.
34 using D::f2;
35 using D::E2;
36 using D::e2;
37 using D::x2;
38 #if __cplusplus >= 201103L
39 // expected-error@-5 {{using declaration refers into 'D::', which is not a base class of 'D2'}}
40 // expected-error@-5 {{using declaration refers into 'D::', which is not a base class of 'D2'}}
41 // expected-error@-5 {{using declaration refers into 'D::', which is not a base class of 'D2'}}
42 // expected-error@-5 {{using declaration refers into 'D::', which is not a base class of 'D2'}}
43 #endif
45 using B::EC;
46 using B::EC::ec; // expected-warning {{a C++20 extension}} expected-warning 0-1 {{C++11}}
49 namespace test1 {
50 struct Base {
51 int foo();
54 struct Unrelated {
55 int foo();
58 struct Subclass : Base {
61 namespace InnerNS {
62 int foo();
65 struct B : Base {
68 // We should be able to diagnose these without instantiation.
69 template <class T> struct C : Base {
70 using InnerNS::foo; // expected-error {{not a class}}
71 using Base::bar; // expected-error {{no member named 'bar'}}
72 using Unrelated::foo; // expected-error {{not a base class}}
74 // In C++98, it's hard to see that these are invalid, because indirect
75 // references to base class members are permitted.
76 using C::foo;
77 using Subclass::foo;
78 #if __cplusplus >= 201103L
79 // expected-error@-3 {{refers to its own class}}
80 // expected-error@-3 {{not a base class}}
81 #endif