[clang] [clang][Sema] Fix rejection of non-dependent void{} during template instantiation (PR #228340)

Daniel Petrovic via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 7 00:13:14 PDT 2026


================
@@ -1687,13 +1687,16 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo,
     // to false.
     bool IsListInit = ListInitialization ||
                       (getLangOpts().HLSL && isa<InitListExpr>(Result.get()));
-    SourceRange Locs = IsListInit
-                           ? SourceRange()
-                           : SourceRange(LParenOrBraceLoc, RParenOrBraceLoc);
-    Result = CXXFunctionalCastExpr::Create(
-        Context, ResultType, Expr::getValueKindForType(Ty), TInfo, CK_NoOp,
-        Result.get(), /*Path=*/nullptr, CurFPFeatureOverrides(),
-        Locs.getBegin(), Locs.getEnd());
+    if (IsListInit)
----------------
daniel-petrovic wrote:

to make here more transparent and avoid code-bloat I'd rather do simply:
```
if (IsListInit) 
   LParenOrBraceLoc  = SourceLocation();

Result = CXXFunctionalCastExpr::Create(
          Context, ResultType, Expr::getValueKindForType(Ty), TInfo, CK_NoOp,
          Result.get(), /*Path=*/nullptr, CurFPFeatureOverrides(),
          LParenOrBraceLoc, RParenOrBraceLoc);

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


More information about the cfe-commits mailing list