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

via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 23 17:08:25 PST 2025


================
@@ -5,6 +5,40 @@
 // RUN: %clang_cc1 -x c++ -Wextra-semi -fixit %t
 // RUN: %clang_cc1 -x c++ -Wextra-semi -Werror %t
 
+#if __cplusplus >= 201103L && defined(PEDANTIC)
+// In C++11 extra semicolons inside classes are allowed via defect reports.
+// expected-no-diagnostics
+class A {
+  void A1();
+  void A2() { };
+  void A2b() { };; 
+  ; 
+  void A2c() { }
+  ;
+  void A3() { };  ;; 
+  ;;;;;;; 
+  ; 
+  ; ;;		 ;  ;;; 
+    ;  ; 	;	;  ;; 
+  void A4();
+
+  union {
+    ;
+    int a;
+    ;
+  };
+};
+
+union B {
+  int a1;
+  int a2;; 
+};
+
----------------
keinflue wrote:

Test cases added, I also removed the `ExtraSemi::AfterMemberFunctionDefinition` special handling for them, because the quirk this is handling does only affect C++98 and pre-DR C++11 and made the warning messages a bit awkward (depending on the number of extra semicolons).

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


More information about the cfe-commits mailing list