diff options
author | Marek Polacek <polacek@redhat.com> | 2021-06-29 14:30:51 -0400 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2021-06-30 12:11:17 -0400 |
commit | e66d0b7b87d105d24da8c4784a0b907fb6b2c095 (patch) | |
tree | 2f138c42691407b73a4c335bad2e43d13620c484 /gcc/cp/decl.c | |
parent | a075350ee7bffa6c90d9d233de78515f498b5149 (diff) | |
download | gcc-e66d0b7b87d105d24da8c4784a0b907fb6b2c095.zip gcc-e66d0b7b87d105d24da8c4784a0b907fb6b2c095.tar.gz gcc-e66d0b7b87d105d24da8c4784a0b907fb6b2c095.tar.bz2 |
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.
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index fa6af6f..7672947 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10969,17 +10969,6 @@ create_array_type_for_decl (tree name, tree type, tree size, location_t loc) if (type == error_mark_node || size == error_mark_node) return error_mark_node; - /* 8.3.4/1: If the type of the identifier of D contains the auto - type-specifier, the program is ill-formed. */ - if (type_uses_auto (type)) - { - if (name) - error_at (loc, "%qD declared as array of %qT", name, type); - else - error ("creating array of %qT", type); - return error_mark_node; - } - /* If there are some types which cannot be array elements, issue an error-message and return. */ switch (TREE_CODE (type)) |