[clang] [C23] Fix compound literals within function prototype (PR #132097)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 19 22:19:51 PDT 2025


================
@@ -7141,7 +7141,13 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
     return ExprError();
   LiteralExpr = Result.get();
 
-  bool isFileScope = !CurContext->isFunctionOrMethod();
+  // We treat the compound literal as being at file scope if it's not in a
+  // function or method body, or within the function's prototype scope. This
+  // means the following compound literal is not at file scope:
+  //   void func(char *para[(int [1]){ 0 }[0]);
+  const Scope *S = getCurScope();
+  bool isFileScope = !CurContext->isFunctionOrMethod() &&
----------------
tbaederr wrote:

```suggestion
  bool IsFileScope = !CurContext->isFunctionOrMethod() &&
```
(Opportunity for cleanup)

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


More information about the cfe-commits mailing list