[clang] [clang][Sema] Expand `#embed` in braced lists that initialize non-aggregates (PR #231938)

Akash Manna via cfe-commits cfe-commits at lists.llvm.org
Sun Oct 18 23:34:57 PDT 2026


================
@@ -5955,8 +5960,7 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
     Result.Standard.setAsIdentityConversion();
     Result.Standard.setFromType(InitTy);
     Result.Standard.setAllToTypes(InitTy);
-    for (unsigned i = 0; i < e; ++i) {
-      Expr *Init = From->getInit(i);
+    for (Expr *Init : From->inits()) {
----------------
akash-manna-sky wrote:

For the conversion sequence, yes: it depends only on type and value category, and narrowing is not part of it (`f({25, 255})` with a single `initializer_list<signed char>` candidate resolves and then fails on narrowing). The narrowing check that runs afterwards is where it mattered: `DiagnoseNarrowingInInitList` evaluated a multi-element `EmbedExpr` as one constant, its first byte, so `signed char x[] = { #embed ... }` never diagnosed a later byte. That check and the C23 constexpr one now test every element.


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


More information about the cfe-commits mailing list