Propagate type attribute when merging extern declarations at local scope.
authorMartin Sebor <msebor@redhat.com>
Thu, 15 Apr 2021 21:49:30 +0000 (15:49 -0600)
committerMartin Sebor <msebor@redhat.com>
Thu, 15 Apr 2021 21:51:00 +0000 (15:51 -0600)
commitda879e01ecd35737c18be1da3324f4560aba1961
treef51df9e8918cf84bc287bbdd0e7f4b9300da023f
parent58fe131b91007793c0f12f5fe6cab3f1a017d0fa
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.
gcc/c/c-decl.c
gcc/testsuite/gcc.dg/Warray-parameter-9.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wnonnull-6.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wreturn-type3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/Wunused-result.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-noreturn.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/attr-returns-nonnull.c [new file with mode: 0644]