[clang] [clang] Allow extra semicolons inside classes also in C++ pedantic mode. (PR #172209)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 1 13:52:55 PST 2026


================
@@ -40,8 +40,12 @@ let CategoryName = "Parse Issue" in {
 def ext_empty_translation_unit : Extension<
   "ISO C requires a translation unit to contain at least one declaration">,
   InGroup<DiagGroup<"empty-translation-unit">>;
-def warn_cxx98_compat_top_level_semi : Warning<
-  "extra ';' outside of a function is incompatible with C++98">,
+def warn_cxx98_compat_extra_semi : Warning<
+  "%select{|||multiple }0extra ';' %select{"
+  "outside of a function|"
+  "inside a %1|"
+  "inside instance variable list|"
----------------
keinflue wrote:

I am also not very familiar with Objective-C, but I added a test case for the "inside instance variable list" of the `ext_extra_semi` diagnostic.

For the `warn_cxx98_compat_extra_semi` and `ext_extra_semi_cxx11` diagnostics, this variant can not happen. The other variants will still occur in usual C++ constructs, but not ObjC-specific constructs. I don't think this is usually tested twice with both `-x c++`/`-x objective-c++`.

This test case made me realize though, that maybe it would be a good idea to also apply the new C++ behavior of allowing semicolons inside classes to Objective-C variable instance lists as well. I don't think there is any specification or reference for this, so maybe someone familiar with Objective-C could give the opinion? I tested GCC and it doesn't provide a warning for this with `-Wextra-semi` or `-pedantic` at all.

https://github.com/llvm/llvm-project/pull/172209


More information about the cfe-commits mailing list