c++: DR2397 - auto specifier for * and & to arrays [PR100975]
This patch implements DR2397, which removes the restriction in
[dcl.array]p4 that the array element type may not be a placeholder
type. We don't need to worry about decltype(auto) here, so this
allows code like
int a[3];
auto (*p)[3] = &a;
auto (&r)[3] = a;
However, note that
auto (&&r)[2] = { 1, 2 };
auto arr[2] = { 1, 2 };
still doesn't work (although one day it might) and neither does
int arr[5];
auto x[5] = arr;
given that auto deduction is performed in terms of function template
argument deduction, so the array decays to *.
PR c++/100975
DR 2397
gcc/cp/ChangeLog:
* decl.c (create_array_type_for_decl): Allow array of auto.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/auto24.C: Remove dg-error.
* g++.dg/cpp0x/auto3.C: Adjust dg-error.
* g++.dg/cpp0x/auto42.C: Likewise.
* g++.dg/cpp0x/initlist75.C: Likewise.
* g++.dg/cpp0x/initlist80.C: Likewise.
* g++.dg/diagnostic/auto1.C: Remove dg-error.
* g++.dg/cpp23/auto-array.C: New test.