Hi, this header (header.h): #pragma GCC system_header int noreturn() { } included by (file.cc): #include "header.h" void ok() { } Leads to: paolo:~/Work> g++ -Wall -c file.cc header.h: In function 'int noreturn()': header.h:2: warning: control reaches end of non-void function Note, this problem doesn't happen if file.cc is compiled as C, thus the problem apparently is the C++ front-end not setting TREE_NO_WARNING on the decl or something similar...
In fact, the problem is of the same type of that in C++/30500: in C++ only when execute_warn_function_return begins in_system_header is zero (in C is 1 and all the warnings are suppressed because diagnostic_report_warnings_p is false)
You can reproduce this in C by using -funit-at-a-time. IMO this is a general bug in unit-at-a-time. Perhaps cgraph_analyze_function or something similar should set in_system_header. Maybe set_cfun.
Thanks Tom, your help is appreciated. Note we have also c++/32368: shall we recategorize both as middle-end bugs then?
Recategorizing is fine by me -- though I wouldn't consider my opinion authoritative :) FWIW I have a patch to set_cfun that appears to fix both these bugs. I'll bootstrap and test it and see what people think.
Cool. Then maybe recategorizing is now just a waste of time ;)
Subject: Bug 32256 Author: tromey Date: Tue Nov 6 15:57:02 2007 New Revision: 129936 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129936 Log: gcc PR c++/32256, PR c++/32368: * function.c (saved_in_system_header): New global. (push_cfun): Save in_system_header. (pop_cfun): Restore in_system_header. (push_struct_function): Save in_system_header. gcc/testsuite PR c++/32368: * g++.dg/warn/pragma-system_header3.h: New. * g++.dg/warn/pragma-system_header3.C: New. PR c++/32256: * g++.dg/warn/pragma-system_header4.C: New. * g++.dg/warn/pragma-system_header4.h: New. Added: trunk/gcc/testsuite/g++.dg/warn/pragma-system_header3.C trunk/gcc/testsuite/g++.dg/warn/pragma-system_header3.h trunk/gcc/testsuite/g++.dg/warn/pragma-system_header4.C trunk/gcc/testsuite/g++.dg/warn/pragma-system_header4.h Modified: trunk/gcc/ChangeLog trunk/gcc/function.c trunk/gcc/testsuite/ChangeLog
Fixed on trunk.
Thanks a lot, Tom!
4.2.4 is being released, changing milestones to 4.2.5.
Closing 4.2 branch, fixed in 4.3.