[clang] [clang] Report narrowing conversions with const references (PR #75332)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 14 06:09:02 PST 2023


================
@@ -10431,7 +10437,7 @@ static void DiagnoseNarrowingInInitList(Sema &S,
                                         : diag::warn_init_list_type_narrowing)
         << PostInit->getSourceRange()
         << PreNarrowingType.getLocalUnqualifiedType()
-        << EntityType.getLocalUnqualifiedType();
+        << EntityType.getLocalUnqualifiedType().getNonReferenceType();
----------------
Fznamznon wrote:

My guess is `getLocalUnqualifiedType` doesn't strip cv qualifiers from reference's pointee type, so we first should remove reference and then qualifiers to see plain `int` in the diagnostic.

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


More information about the cfe-commits mailing list