[clang] [C] Add -Wduplicate-decl-specifier to -Wc++-compat (PR #138012)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri May 2 04:40:35 PDT 2025


================
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wduplicate-decl-specifier %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wc++-compat %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-duplicate-decl-specifier -Wc++-compat %s
+// RUN: %clang_cc1 -fsyntax-only -verify=good -Wc++-compat -Wno-duplicate-decl-specifier %s
+// RUN: %clang_cc1 -fsyntax-only -verify=good -Wno-duplicate-decl-specifier %s
+// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s
+// good-no-diagnostics
+
+// Note: we treat this as a warning in C++, so you get the same diagnostics in
+// either language mode. However, GCC diagnoses this as an error, so the
+// compatibility warning has value.
+const const int i = 12; // expected-warning {{duplicate 'const' declaration specifier}}
----------------
AaronBallman wrote:

Sure! I added that in f33dc8e4388cb1cc6a9212bc0618542c80b5c1ee

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


More information about the cfe-commits mailing list