65 lines · cpp
1// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s2 3template <typename T> static void destroy() {4 T t;5 ++t;6}7 8struct Incomplete;9 10template <typename = int> struct HasD {11 ~HasD() { destroy<Incomplete*>(); }12};13 14struct HasVT {15 virtual ~HasVT();16};17 18struct S : HasVT {19 HasD<> v;20};21 22// Ensure we don't get infinite recursion from the check, however. See GH10480223namespace GH104802 {24class 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 30class 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 36class 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 43class 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 GH14178950namespace GH141789 {51template <typename Ty>52struct S {53 Ty t; // expected-error {{field has incomplete type 'GH141789::X'}}54};55 56struct T {57 ~T();58};59 60struct 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}65