[clang] [C2y] Implement WG14 N3622 static used in an inline (PR #162877)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 10 09:25:52 PDT 2025
================
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify=good -pedantic -Wall -std=c2y %s
+// RUN: %clang_cc1 -verify -pedantic -Wall -std=c23 %s
+// RUN: %clang_cc1 -verify -pedantic -Wall -std=c17 %s
+// good-no-diagnostics
+
+/* WG14 N3622: Clang 22
+ * Allow calling static inline within extern inline
+ *
+ * This verifies that a constraint from previous standards is no longer
+ * triggered in C2y mode. The constraint is with calling a statric function
+ * or using a static variable from an inline function with external linkage.
+ */
+
+static void static_func(void) {} // expected-note {{declared here}}
+static int static_var; // expected-note {{declared here}}
+
+extern inline void test(void) {
+ static_func(); // expected-warning {{static function 'static_func' is used in an inline function with external linkage}}
----------------
AaronBallman wrote:
The diagnostic wording is existing code and I think is slightly more clear when you think about uses of static functions other than calls, like:
```
static void static_func(void) {}
extern inline void foo(void) {
void (*fp)(void) = static_func; // This is similarly "bad" but there's no call in sight
}
```
https://github.com/llvm/llvm-project/pull/162877
More information about the cfe-commits
mailing list