[clang] [Clang] support storage-class specifiers in C23 compound literals (PR #212559)

Oleksandr Tarasiuk via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 1 08:50:36 PDT 2026


================
@@ -167,6 +172,14 @@ class DelayedDiagnostic {
     return DD;
   }
 
+  static DelayedDiagnostic makeForbiddenStatic(SourceLocation Loc) {
----------------
a-tarasyuk wrote:

I added a delayed diagnostic to handle the following two cases.

```c
inline int f13(int a[(static int){1}]) { // expected-warning {{non-constant static local variable in inline function may be different in different files}} \
                                         // expected-note {{use 'static' to give inline function 'f13' internal linkage}}
  return a[0];
}

inline int f14(int a[(static int){1}]);
```

When `BuildCompoundLiteralExpr` runs, the `FunctionDecl` is not yet complete, so it's not possible to tell whether it's a prototype or an inline definition. Once parsing is complete, f13 should produce a warning, while the f14 prototype should not.

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


More information about the cfe-commits mailing list