[clang] [C] Add -Wduplicate-decl-specifier to -Wc++-compat (PR #138012)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Thu May 1 17:18:57 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}}
----------------
shafik wrote:
`volatile const volatile const int x = 1;` might also be worth checking, to get in `volatile` and test that we catch alternating qualifies.
https://github.com/llvm/llvm-project/pull/138012
More information about the cfe-commits
mailing list