Index: clang/include/clang/Basic/DiagnosticGroups.td =================================================================== --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -1133,6 +1133,12 @@ // A warning group for warnings about code that may be incompatible on AIX. def AIXCompat : DiagGroup<"aix-compat">; +// Warnings for Plan 9 extensions. +def Plan9AnonTag : DiagGroup<"plan9-anon-tag">; + +// Warnings group for warnings about Plan 9 extensions. +def Plan9 : DiagGroup<"plan9", [Plan9AnonTag]>; + // Warnings for Microsoft extensions. def MicrosoftCharize : DiagGroup<"microsoft-charize">; def MicrosoftDrectveSection : DiagGroup<"microsoft-drectve-section">; Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -9011,6 +9011,9 @@ def ext_ms_anonymous_record : ExtWarn< "anonymous %select{structs|unions}0 are a Microsoft extension">, InGroup; +def ext_plan9_anonymous_record : ExtWarn< + "anonymous %select{structs|unions}0 are a Plan 9 extension">, + InGroup; // C++ local classes def err_reference_to_local_in_enclosing_context : Error< Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -4989,8 +4989,10 @@ else if (const RecordType *UT = DS.getRepAsType().get()->getAsUnionType()) Record = UT->getDecl(); - if (Record && getLangOpts().MicrosoftExt) { - Diag(DS.getBeginLoc(), diag::ext_ms_anonymous_record) + if (Record && (getLangOpts().MicrosoftExt || getLangOpts().Plan9)) { + Diag(DS.getBeginLoc(), getLangOpts().MicrosoftExt + ? diag::ext_ms_anonymous_record + : diag::ext_plan9_anonymous_record) << Record->isUnion() << DS.getSourceRange(); return BuildMicrosoftCAnonymousStruct(S, DS, Record); } Index: clang/test/Sema/2c-anon-record.c =================================================================== --- /dev/null +++ clang/test/Sema/2c-anon-record.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 %s -fsyntax-only -Wplan9 -verify -fplan9-extensions + +struct A { + int x; +}; + +struct B { + struct A; // expected-warning {{anonymous structs are a Plan 9 extension}} +};