diff options
author | Martin Sebor <msebor@redhat.com> | 2021-04-15 15:49:30 -0600 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2021-04-15 15:51:00 -0600 |
commit | da879e01ecd35737c18be1da3324f4560aba1961 (patch) | |
tree | f51df9e8918cf84bc287bbdd0e7f4b9300da023f /gcc/c/c-decl.c | |
parent | 58fe131b91007793c0f12f5fe6cab3f1a017d0fa (diff) | |
download | gcc-da879e01ecd35737c18be1da3324f4560aba1961.zip gcc-da879e01ecd35737c18be1da3324f4560aba1961.tar.gz gcc-da879e01ecd35737c18be1da3324f4560aba1961.tar.bz2 |
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.
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r-- | gcc/c/c-decl.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 3c25451..3ea4708 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -3263,11 +3263,10 @@ pushdecl (tree x) else thistype = type; b->u.type = TREE_TYPE (b->decl); - if (TREE_CODE (b->decl) == FUNCTION_DECL - && fndecl_built_in_p (b->decl)) - thistype - = build_type_attribute_variant (thistype, - TYPE_ATTRIBUTES (b->u.type)); + /* Propagate the type attributes to the decl. */ + thistype + = build_type_attribute_variant (thistype, + TYPE_ATTRIBUTES (b->u.type)); TREE_TYPE (b->decl) = thistype; bind (name, b->decl, scope, /*invisible=*/false, /*nested=*/true, locus); |