[Bug c/99420] [11 Regression] bogus -Warray-parameter on a function redeclaration in function scope

2021-04-15 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99420

Martin Sebor  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #8 from Martin Sebor  ---
Fix committed in r11-8205.

[Bug c/99420] [11 Regression] bogus -Warray-parameter on a function redeclaration in function scope

2021-04-15 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99420

--- Comment #7 from CVS Commits  ---
The master branch has been updated by Martin Sebor :

https://gcc.gnu.org/g:da879e01ecd35737c18be1da3324f4560aba1961

commit r11-8205-gda879e01ecd35737c18be1da3324f4560aba1961
Author: Martin Sebor 
Date:   Thu Apr 15 15:49:30 2021 -0600

Propagate type attribute when merging extern declarations at local scope.

Resolves:
PR c/99420 - bogus -Warray-parameter on a function redeclaration in
function scope
PR c/99972 - missing -Wunused-result on a call to a locally redeclared
warn_unused_result function

gcc/c/ChangeLog:

PR c/99420
PR c/99972
* c-decl.c (pushdecl): Always propagate type attribute.

gcc/testsuite/ChangeLog:

PR c/99420
PR c/99972
* gcc.dg/Warray-parameter-9.c: New test.
* gcc.dg/Wnonnull-6.c: New test.
* gcc.dg/Wreturn-type3.c: New test.
* gcc.dg/Wunused-result.c: New test.
* gcc.dg/attr-noreturn.c: New test.
* gcc.dg/attr-returns-nonnull.c: New test.

[Bug c/99420] [11 Regression] bogus -Warray-parameter on a function redeclaration in function scope

2021-04-08 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99420

Martin Sebor  changed:

   What|Removed |Added

   Keywords||patch
 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |msebor at gcc dot 
gnu.org

--- Comment #6 from Martin Sebor  ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-April/567800.html

[Bug c/99420] [11 Regression] bogus -Warray-parameter on a function redeclaration in function scope

2021-04-08 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99420

Martin Sebor  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=99972

--- Comment #5 from Martin Sebor  ---
The attributes need to be copied/merged across redeclarations of the same
symbol regardless of the scope.  See pr99972 for another example where failing
to do it causes a false positive.

[Bug c/99420] [11 Regression] bogus -Warray-parameter on a function redeclaration in function scope

2021-04-08 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99420

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org,
   ||jsm28 at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek  ---
If not copying over the attribute is intentional when it isn't builtin, we
could still copy over just the single attribute, like:
--- gcc/c/c-decl.c.jj   2021-03-16 00:21:29.464233163 +0100
+++ gcc/c/c-decl.c  2021-04-08 18:19:24.762093841 +0200
@@ -3268,6 +3268,17 @@ pushdecl (tree x)
thistype
  = build_type_attribute_variant (thistype,
  TYPE_ATTRIBUTES (b->u.type));
+ else if (!lookup_attribute ("access", TYPE_ATTRIBUTES (thistype)))
+   if (tree access = lookup_attribute ("access",
+   TYPE_ATTRIBUTES (b->u.type)))
+ {
+   /* Otherwise, copy over the access attribute.  */
+   tree attr = tree_cons (TREE_PURPOSE (access),
+  TREE_VALUE (access),
+  TYPE_ATTRIBUTES (thistype));
+   thistype
+ = build_type_attribute_variant (thistype, attr);
+ }
  TREE_TYPE (b->decl) = thistype;
  bind (name, b->decl, scope, /*invisible=*/false, /*nested=*/true,
locus);
Except that the access attribute unfortunately seems to mean a lot of different
things, it is a user attribute with some arguments that is later rewritten into
a different form and that other form is reused also for the array parameters
and the -Warray-parameter stuff using that.
So, if both decls of f1 should have different attributes, then doing the above
is undesirable because it would also result in user's access attributes being
copied over, or that for user access attribute on the second declaration would
result in it not being copied.
Perhaps we can copy the attribute under a different attribute name (something
with space in it so that it isn't user accessible) and use that for
-Warray-parameter purposes in preference over "access"?
Also, I'd argue that the rewritten "access" attribute shouldn't be called
"access" but with some internal name.

[Bug c/99420] [11 Regression] bogus -Warray-parameter on a function redeclaration in function scope

2021-04-08 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99420

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P1

[Bug c/99420] [11 Regression] bogus -Warray-parameter on a function redeclaration in function scope

2021-03-16 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99420

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |11.0