82 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s2// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s3// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s4 5struct rdar9677163 {6 struct Y { ~Y(); };7 struct Z { ~Z(); };8 Y::~Y() { } // expected-error{{non-friend class member '~Y' cannot have a qualified name}}9 ~Z(); // expected-error{{expected the class name after '~' to name the enclosing class}}10};11 12namespace GH56772 {13 14template<class T>15struct A {16 ~A<T>();17};18#if __cplusplus >= 202002L19// FIXME: This isn't valid in C++20 and later.20#endif21 22struct B;23 24template<class T>25struct C {26 ~B(); // expected-error {{expected the class name after '~' to name the enclosing class}}27};28 29template <typename T>30struct D {31 friend T::S::~S();32private:33 static constexpr int secret = 42;34};35 36template <typename T>37struct E {38 friend T::S::~V();39};40 41struct BadInstantiation {42 struct S {43 struct V {};44 };45};46 47struct GoodInstantiation {48 struct V {49 ~V();50 };51 using S = V;52};53 54// FIXME: We should diagnose this while instantiating.55E<BadInstantiation> x;56E<GoodInstantiation> y;57 58struct Q {59 struct S { ~S(); };60};61 62Q::S::~S() {63 void foo(int);64 foo(D<Q>::secret);65}66 67struct X {68 ~X();69};70struct Y;71 72struct Z1 {73 friend X::~Y(); // expected-error {{expected the class name after '~' to name the enclosing class}}74};75 76template <class T>77struct Z2 {78 friend X::~Y(); // expected-error {{expected the class name after '~' to name the enclosing class}}79};80 81}82