[PATCH] D147909: [clang] Implement CWG 2397
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 11 08:25:29 PDT 2023
aaron.ballman added a reviewer: clang-language-wg.
aaron.ballman added a comment.
The changes need a release note, but also this should have changes to `clang/test/CXX/drs/dr23xx.cpp` with the proper dr markings and update `clang/www/cxx_dr_status.html`.
================
Comment at: clang/test/CXX/dcl.decl/dcl.meaning/dcl.array/cwg2397.cpp:11
+}
+
+void g() {
----------------
I think it'd be good to also show a constexpr test, like:
```
constexpr int foo() {
int a[] = { 1, 2, 3 };
auto (&c)[3] = a;
return c[2];
}
static_assert(foo() == 3, "");
```
to prove that we actually perform the assignment properly, not just figure out the deduced type correctly.
================
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]'}}
----------------
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.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147909/new/
https://reviews.llvm.org/D147909
More information about the cfe-commits
mailing list