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