aboutsummaryrefslogtreecommitdiff
path: root/gcc/attribs.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2020-09-30 12:58:09 -0600
committerMartin Sebor <msebor@redhat.com>2020-09-30 12:59:53 -0600
commit7dbc7ad524a540e34ce25d120d0968f36c571bbb (patch)
tree245770a1d21bc0447338a70798ca0796c1bebf59 /gcc/attribs.c
parente808f3fdfa8f31066da19011b55acb8c0446c72d (diff)
downloadgcc-7dbc7ad524a540e34ce25d120d0968f36c571bbb.zip
gcc-7dbc7ad524a540e34ce25d120d0968f36c571bbb.tar.gz
gcc-7dbc7ad524a540e34ce25d120d0968f36c571bbb.tar.bz2
Avoid assuming a VLA access specification string contains a closing bracket (PR middle-end/97189).
Resolves: PR middle-end/97189 - ICE on redeclaration of a function with VLA argument and attribute access gcc/ChangeLog: PR middle-end/97189 * attribs.c (attr_access::array_as_string): Avoid assuming a VLA access specification string contains a closing bracket. gcc/c-family/ChangeLog: PR middle-end/97189 * c-attribs.c (append_access_attr): Use the function declaration location for a warning about an attribute access argument. gcc/testsuite/ChangeLog: PR middle-end/97189 * gcc.dg/attr-access-2.c: Adjust caret location. * gcc.dg/Wvla-parameter-6.c: New test. * gcc.dg/Wvla-parameter-7.c: New test.
Diffstat (limited to 'gcc/attribs.c')
-rw-r--r--gcc/attribs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/attribs.c b/gcc/attribs.c
index 3f6ec3d..94b9e02 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -2270,11 +2270,11 @@ attr_access::array_as_string (tree type) const
bound is nonconstant and whose access string has "$]" in it)
extract the bound expression from SIZE. */
const char *p = end;
- for ( ; *p-- != ']'; );
+ for ( ; p != str && *p-- != ']'; );
if (*p == '$')
index_type = build_index_type (TREE_VALUE (size));
}
- else if (minsize)
+ else if (minsize)
index_type = build_index_type (size_int (minsize - 1));
tree arat = NULL_TREE;