71 lines · cpp
1// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify %s2// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s3// RUN: %clang_cc1 -fsyntax-only -verify %s4 5struct B {6 void f(char);7 void g(char);8 enum E { e };9 union { int x; };10 11 enum class EC { ec }; // expected-warning 0-1 {{C++11}}12 13 void f2(char);14 void g2(char);15 enum E2 { e2 };16 union { int x2; };17};18 19class C {20public:21 int g();22};23 24struct D : B {};25 26class 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'}}32 33 using D::f2; // expected-error {{using declaration refers into 'D', which is not a base class of 'D2'}}34 using D::E2; // expected-error {{using declaration refers into 'D', which is not a base class of 'D2'}}35 using D::e2; // expected-error {{using declaration refers into 'D', which is not a base class of 'D2'}}36 using D::x2; // expected-error {{using declaration refers into 'D', which is not a base class of 'D2'}}37 38 using B::EC;39 using B::EC::ec; // expected-warning {{a C++20 extension}} expected-warning 0-1 {{C++11}}40};41 42namespace test1 {43 struct Base {44 int foo();45 };46 47 struct Unrelated {48 int foo();49 };50 51 struct Subclass : Base {52 };53 54 namespace InnerNS {55 int foo();56 }57 58 struct B : Base {59 };60 61 // We should be able to diagnose these without instantiation.62 template <class T> struct C : Base {63 using InnerNS::foo; // expected-error {{not a class}}64 using Base::bar; // expected-error {{no member named 'bar'}}65 using Unrelated::foo; // expected-error {{not a base class}}66 67 using C::foo; // expected-error {{refers to its own class}}68 using Subclass::foo; // expected-error {{not a base class}}69 };70}71