We can't look at the bases and members of a forward-declared nested class,
and such a forward declaration can't contain problematic constructs, so
treat it as OK.
PR c++/126031
PR c++/121552
gcc/cp/ChangeLog:
* decl.cc (maybe_diagnose_non_c_class_typedef_for_linkage): Handle
incomplete type.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/typedef2.C: New test.
static bool
maybe_diagnose_non_c_class_typedef_for_linkage (tree type, tree orig, tree t)
{
+ if (!COMPLETE_TYPE_P (t))
+ return false;
if (!BINFO_BASE_BINFOS (TYPE_BINFO (t))->is_empty ())
{
auto_diagnostic_group d;
--- /dev/null
+// PR c++/126031
+
+typedef struct {
+ struct S;
+} s;