diff options
author | Martin Uecker <uecker@tugraz.at> | 2023-05-26 11:19:01 +0200 |
---|---|---|
committer | Martin Uecker <uecker@tugraz.at> | 2023-05-26 22:40:28 +0200 |
commit | 8d6bd830f5f9c939e8565c0341a0c6c588834484 (patch) | |
tree | 3166e14e82eff312bfd4aea581dac5144a0c9f96 /gcc/c-family/c-attribs.cc | |
parent | a1b23dcf2337ab8666fac7d1e191ca987710d184 (diff) | |
download | gcc-8d6bd830f5f9c939e8565c0341a0c6c588834484.zip gcc-8d6bd830f5f9c939e8565c0341a0c6c588834484.tar.gz gcc-8d6bd830f5f9c939e8565c0341a0c6c588834484.tar.bz2 |
c: -Wstringop-overflow for parameters with forward-declared sizes
Warnings from -Wstringop-overflow do not appear for parameters declared
as VLAs when the bound refers to a parameter forward declaration. This
is fixed by splitting the loop that passes through parameters into two,
first only recording the positions of all possible size expressions
and then processing the parameters.
PR c/109970
gcc/c-family:
* c-attribs.cc (build_attr_access_from_parms): Split loop to first
record all parameters.
gcc/testsuite:
* gcc.dg/pr109970.c: New test.
Diffstat (limited to 'gcc/c-family/c-attribs.cc')
-rw-r--r-- | gcc/c-family/c-attribs.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc index 072cfb6..e2792ca 100644 --- a/gcc/c-family/c-attribs.cc +++ b/gcc/c-family/c-attribs.cc @@ -5278,6 +5278,15 @@ build_attr_access_from_parms (tree parms, bool skip_voidptr) tree argtype = TREE_TYPE (arg); if (DECL_NAME (arg) && INTEGRAL_TYPE_P (argtype)) arg2pos.put (arg, argpos); + } + + argpos = 0; + for (tree arg = parms; arg; arg = TREE_CHAIN (arg), ++argpos) + { + if (!DECL_P (arg)) + continue; + + tree argtype = TREE_TYPE (arg); tree argspec = DECL_ATTRIBUTES (arg); if (!argspec) |