Debian Codegraph @

clang/test/SemaCXX/gh102293.cpp

raw
1 // RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
2
3 template <typename T> static void destroy() {
4 T t;
5 ++t;
6 }
7
8 struct Incomplete;
9
10 template <typename = int> struct HasD {
11 ~HasD() { destroy<Incomplete*>(); }
12 };
13
14 struct HasVT {
15 virtual ~HasVT();
16 };
17
18 struct S : HasVT {
19 HasD<> v;
20 };
21
22 // Ensure we don't get infinite recursion from the check, however. See GH104802
23 namespace GH104802 {
24 class foo { // expected-note {{definition of 'GH104802::foo' is not complete until the closing '}'}}
25 foo a; // expected-error {{field has incomplete type 'foo'}}
26
27 virtual int c();
28 };
29
30 class bar { // expected-note {{definition of 'GH104802::bar' is not complete until the closing '}'}}
31 const bar a; // expected-error {{field has incomplete type 'const bar'}}
32
33 virtual int c();
34 };
35
36 class baz { // expected-note {{definition of 'GH104802::baz' is not complete until the closing '}'}}
37 typedef class baz blech;
38 blech a; // expected-error {{field has incomplete type 'blech' (aka 'class baz')}}
39
40 virtual int c();
41 };
42
43 class quux : quux { // expected-error {{base class has incomplete type}} \
44 expected-note {{definition of 'GH104802::quux' is not complete until the closing '}'}}
45 virtual int c();
46 };
47 }
48
49 // Ensure we don't get infinite recursion from the check, however. See GH141789
50 namespace GH141789 {
51 template <typename Ty>
52 struct S {
53 Ty t; // expected-error {{field has incomplete type 'GH141789::X'}}
54 };
55
56 struct T {
57 ~T();
58 };
59
60 struct X { // expected-note {{definition of 'GH141789::X' is not complete until the closing '}'}}
61 S<X> next; // expected-note {{in instantiation of template class 'GH141789::S<GH141789::X>' requested here}}
62 T m;
63 };
64 }