[clang] [clang][Parse] Fix __extension__ not silencing diagnostics (PR #221623)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 7 21:01:11 PDT 2026


================
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify -std=c17
+// RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify -std=c2y
+// RUN: %clang_cc1 %s -fsyntax-only -pedantic -verify -x c++ -std=c++17
+
+// expected-no-diagnostics
+
+int f(int);
+
+void cond(int a) {
+  if (__extension__ ({ int r = f(a); r; })) {}
+  while (__extension__ ({ int r = f(a); r; })) { break; }
+  switch (__extension__ ({ int r = f(a); r; })) { default: break; }
+  do {} while (__extension__ ({ int r = f(a); r; }));
+  for (; __extension__ ({ int r = f(a); r; });) { break; }
+}
----------------
zhangweize9-cyber wrote:

You can try the test case `int r = ({ ; });` to see if it passes the test.

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


More information about the cfe-commits mailing list