aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!



================
Comment at: clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/p1-cxx0x.cpp:5
   int b[5];
-  auto a[5] = b; // expected-error{{'a' declared as array of 'auto'}}
-  auto *c[5] = b; // expected-error{{'c' declared as array of 'auto *'}}
+  auto a[5] = b; // expected-error{{variable 'a' with type 'auto[5]' has 
incompatible initializer of type 'int[5]'}}
+  auto *c[5] = b; // expected-error{{variable 'c' with type 'auto *[5]' has 
incompatible initializer of type 'int[5]'}}
----------------
zyounan wrote:
> aaron.ballman wrote:
> > I've seen worse diagnostics, but the phrasing here is interesting -- if you 
> > use `int a[5] = b;` instead of `auto`, you get `array initializer must be 
> > an initializer list` as a diagnostic, so I wonder why we're getting such a 
> > drastically different diagnostic for `auto`. Same for the diagnostic below.
> You're right that such diagnostic looks a bit strange but FYI, GCC now emits 
> diagnostic like so:
> ```
> auto a[5] = b; // error: unable to deduce 'auto [5]' from 'b'
> int c[5] = b;  // error: array must be initialized with a brace-enclosed 
> initializer
> ```
> I agree that what we expect here is to emit messages just like `int a[5] = 
> b;` would produce with respect to better understandability, however, the 
> `err_auto_var_deduction_failure` error is actually emitted due to type 
> deduction failure, whereas `err_array_init_not_init_list` would be produced 
> **later** by initialization error IIUC. So, IMHO such message makes sence as 
> per what standard says, that for each type `P`, after being substituted with 
> deduced `A`, shall be **compatible** with type `A`. 
> [temp.deduct.type/1](https://eel.is/c++draft/temp.deduct.type#1.sentence-1)
> 
> // Feel free to correct me if I'm wrong :)
Ah, good catch! Okay, this seems reasonable to me now that I understand it 
better, thank you.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147909/new/

https://reviews.llvm.org/D147909

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to