[Bug c/99972] missing -Wunused-result on a call to a locally redeclared warn_unused_result function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99972 Martin Sebor changed: What|Removed |Added Target Milestone|--- |11.0 Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #5 from Martin Sebor --- Fix committed in r11-8205.
[Bug c/99972] missing -Wunused-result on a call to a locally redeclared warn_unused_result function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99972 --- Comment #4 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/99972] missing -Wunused-result on a call to a locally redeclared warn_unused_result function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99972 Martin Sebor changed: What|Removed |Added Ever confirmed|0 |1 Assignee|unassigned at gcc dot gnu.org |msebor at gcc dot gnu.org Last reconfirmed||2021-04-08 Keywords||patch Status|UNCONFIRMED |ASSIGNED --- Comment #3 from Martin Sebor --- Patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-April/567800.html
[Bug c/99972] missing -Wunused-result on a call to a locally redeclared warn_unused_result function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99972 --- Comment #2 from Martin Sebor --- The code (obviously) needs to be compiled as C to show the C bug (the C++ front end is also buggy but differently; pr99974 tracks that): $ gcc -S -Wall pr99972.c pr99972.c: In function ‘gwur’: pr99972.c:20:3: warning: ignoring return value of ‘fwur’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | fwur (); // -Wunused-result (good) | ^~~
[Bug c/99972] missing -Wunused-result on a call to a locally redeclared warn_unused_result function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99972 Martin Sebor changed: What|Removed |Added Known to fail||10.2.0, 11.0, 4.7.0, 4.8.4, ||4.9.4, 5.5.0, 6.4.0, 7.2.0, ||8.3.0, 9.1.0 Keywords||diagnostic --- Comment #1 from Martin Sebor --- This never worked correctly so it's not a regression. Clang does the right thing and warns where expected: z.c:20:3: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result] fwur (); // -Wunused-result (good) ^~~~ z.c:27:3: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result] fwur (); // missing -Wunused-result (bug) ^~~~ 2 warnings generated.