Hi, macOS SDK headers using the CF_ENUM macro can expand to invalid C++ code of the form: typedef enum T : BaseType T; i.e. an elaborated-type-specifier with an additional enum-base. Upstream LLVM can be made to accept the above construct with -Wno-error=elaborated-enum-base. This macro expansion occurs in the case that the compiler declares support for enums with underlying type using __has_feature, see https://gcc.gnu.org/pipermail/gcc-patches/2023-May/618450.html GCC rejecting this construct outright means that GCC fails to bootstrap on Darwin in the case that it (correctly) implements __has_feature and declares support for C++ enums with underlying type. This patch attempts to accept this construct in the C++ parser but only if it appears in system headers. With this patch, GCC can bootstrap on Darwin in combination with the (WIP) __has_feature patch posted at: https://gcc.gnu.org/pipermail/gcc-patches/2023-May/617878.html We also attempt to improve the diagnostic for this case, using a similar diagnostic to that given by LLVM. If it is more palatable I can look into restricting the change to accept this code to only take effect on Darwin, but it's not clear that that's any better or worse. Other possible approaches here include trying to fixincludes the SDK framework headers, but as Iain pointed out in the review of the has_feature RFC, the necessary infrastructure doesn't exist at the moment. Even if this support did exist, I believe the headers would require quite extensive non-trivial "fixing". Adjusting the parser to accept this construct in system headers seemed more pragmatic and cleaner on balance. Bootstrapped/regtested on aarch64-linux-gnu and x86_64-apple-darwin. Any thoughts? Thanks, Alex gcc/cp/ChangeLog: * parser.cc (cp_parser_enum_specifier): Accept elaborated-type-specifier with enum-base if in system headers. Improve diagnostic when rejecting such a construct. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/enum40.C: Adjust expected diagnostics. * g++.dg/cpp0x/forw_enum6.C: Likewise. * g++.dg/ext/elab-enum-header.C: New test. * g++.dg/ext/elab-enum-invalid.C: New test.