[Bug c++/84294] attributes on a function template redeclaration silently discarded
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84294 Martin Sebor changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #4 from Martin Sebor --- Fixed in r258121.
[Bug c++/84294] attributes on a function template redeclaration silently discarded
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84294 --- Comment #3 from Martin Sebor --- Author: msebor Date: Fri Mar 2 00:16:52 2018 New Revision: 258121 URL: https://gcc.gnu.org/viewcvs?rev=258121&root=gcc&view=rev Log: PR c++/84294 - attributes on a function template redeclaration silently discarded gcc/cp/ChangeLog: PR c++/84294 * decl.c (check_redeclaration_no_default_args): Merge attributes specified on redeclarations of the same function template. Remove dead code. gcc/testsuite/ChangeLog: PR c++/84294 * g++.dg/ext/attr-const.C: Remove xfail. * g++.dg/ext/attr-malloc-3.C: New test. * g++.dg/ext/attr-noinline-3.C: New test. * g++.dg/ext/attr-noreturn-3.C: New test. * g++.dg/ext/attr-nothrow-3.C: New test. * g++.dg/ext/attr-pure.C: Remove xfail. Added: trunk/gcc/testsuite/g++.dg/ext/attr-noinline-3.C trunk/gcc/testsuite/g++.dg/ext/attr-noreturn-3.C trunk/gcc/testsuite/g++.dg/ext/attr-nothrow-3.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/ext/attr-const.C trunk/gcc/testsuite/g++.dg/ext/attr-malloc-3.C trunk/gcc/testsuite/g++.dg/ext/attr-pure.C
[Bug c++/84294] attributes on a function template redeclaration silently discarded
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84294 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 #2 from Martin Sebor --- Patch: https://gcc.gnu.org/ml/gcc-patches/2018-02/msg01625.html
[Bug c++/84294] attributes on a function template redeclaration silently discarded
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84294 Martin Sebor changed: What|Removed |Added Keywords||missed-optimization Status|UNCONFIRMED |NEW Last reconfirmed||2018-02-28 Summary|missing warning for ignored |attributes on a function |attribute on a function |template redeclaration |template declaration|silently discarded Ever confirmed|0 |1 Known to fail||6.4.0, 7.3.0, 8.0 --- Comment #1 from Martin Sebor --- I'll confirm this bug because it was the indirect cause of a number of test suite regressions recently (bug 84617). The problem is also not just one of a missing diagnostic but rather one of G++ failing to apply attributes specified on a function template re-declaration that were not specified on the first declaration of the template. I.e., it's a missed optimization opportunity. An enhanced test case: $cat b.C && gcc -O2 -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout b.C int f (); int __attribute__ ((const)) f (); void ff () { int i0 = f (); int i1 = f (); if (i0 != i1) // folded to false __builtin_abort (); } template int g (); template int __attribute__ ((const)) g (); void gg () { int i0 = g(); int i1 = g(); if (i0 != i1) // not folded __builtin_abort (); } template int __attribute__ ((const)) h (); template int h (); void hh () { int i0 = h(); int i1 = h(); if (i0 != i1) // folded to false __builtin_abort (); } ;; Function ff (_Z2ffv, funcdef_no=0, decl_uid=2361, cgraph_uid=0, symbol_order=0) ff () { [local count: 1073741825]: return; } ;; Function gg (_Z2ggv, funcdef_no=1, decl_uid=2371, cgraph_uid=1, symbol_order=1) gg () { int _3; int _5; [local count: 1073741825]: _3 = g (); _5 = g (); if (_3 != _5) goto ; [0.00%] else goto ; [99.96%] [count: 0]: __builtin_abort (); [local count: 1073312327]: return; } ;; Function hh (_Z2hhv, funcdef_no=4, decl_uid=2382, cgraph_uid=2, symbol_order=2) hh () { [local count: 1073741825]: return; }