[clang] [Clang] Diagnose UB and emit error when identifier has both internal and external linkage (PR #192116)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 22 01:24:58 PDT 2026
================
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++17 %s
+
+// expected-no-diagnostics
+
+// CWG 426 / [basic.link]p6: the same identifier with both internal and
+// external linkage should be ill-formed in C++, but Clang does not yet
+// diagnose this due to ABI break concerns. This test documents current
+// behavior.
+
+static int x;
+void test_shadow(void) {
+ int x;
+ {
+ // FIXME: Per CWG 426, this should be ill-formed because the
+ // file-scope 'x' has internal linkage but this 'extern' gets
+ // external linkage due to the local shadow.
----------------
Endilll wrote:
Nothing to fix here: this `x` already has internal linkage.
https://github.com/llvm/llvm-project/pull/192116
More information about the cfe-commits
mailing list