[clang] [Clang] Reland "Diagnose UB and emit error when identifier has both internal and external linkage" (PR #193567)

Aditya Medhane via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 19 03:43:25 PDT 2026


================
@@ -1,45 +1,106 @@
-// RUN: %clang_cc1 -verify -std=c2y -Wall -pedantic -Wno-unused %s
+// RUN: %clang_cc1 -verify=c2y -std=c2y -Wall -pedantic -Wno-unused %s
+// RUN: %clang_cc1 -verify=c89-23 -std=c23 -Wall -pedantic -Wno-unused %s
+// RUN: %clang_cc1 -verify=c89-23 -std=c17 -Wall -pedantic -Wno-unused %s
+// RUN: %clang_cc1 -verify=c89-23 -std=c11 -Wall -pedantic -Wno-unused %s
+// RUN: %clang_cc1 -verify=c89-23 -std=c99 -Wall -pedantic -Wno-unused %s
+// RUN: %clang_cc1 -verify=c89-23 -std=c89 -Wall -pedantic -Wno-unused -Wno-comment %s
 
-/* WG14 N3410: No
+/* WG14 N3410: Clang 23
  * Slay Some Earthly Demons XI
  *
  * It is now ill-formed for the same identifier within a TU to have both
  * internal and external linkage.
  */
 
-void func1() {
-  extern int a; // #a
+void func1(void) {
+  extern int a; /* #a */
 }
 
-// This 'a' is the same as the one declared extern above.
-static int a; /* expected-error {{static declaration of 'a' follows non-static declaration}}
-                 expected-note@#a {{previous declaration is here}}
+/* This 'a' is the same as the one declared extern above. */
+static int a; /* c2y-error {{static declaration of 'a' follows non-static declaration}}
+                 c2y-note@#a {{previous declaration is here}}
+                 c89-23-error {{static declaration of 'a' follows non-static declaration}}
----------------
flash1729 wrote:

Makes sense. I'd leaned toward keeping it consistent with the other diagnostic, but since the suffix was @AaronBallman's suggestion, I'll leave the final call to him.

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


More information about the cfe-commits mailing list