================
@@ -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:

> Since this is supposed to remove local qualifiers, should the reference be 
> removed first? What happens with a const int & as is?

Perhaps makes sense. I only removed reference since it is already removed from 
the pre-narrowing-type and I was a bit inspired by gcc messages 
https://godbolt.org/z/Tcv17Wxhc . I could leave reference type it as is, then 
the messages will look like:

```

struct A { A(const unsigned &x) {} };

int foo(const int &aba) {
    A a { -1 }; // constant expression evaluates to -1 which cannot be narrowed 
to type 'const unsigned int&'
    A b { aba }; // non-constant-expression cannot be narrowed from type 'int' 
to 'const unsigned int' in initializer list
    return 0;
}
```

https://github.com/llvm/llvm-project/pull/75332
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to