Bug 32256 - [4.2 Regression] pragma system_header doesn't suppress warnings in tree-cfg
Summary: [4.2 Regression] pragma system_header doesn't suppress warnings in tree-cfg
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P2 normal
Target Milestone: 4.3.0
Assignee: Tom Tromey
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2007-06-08 15:30 UTC by Paolo Carlini
Modified: 2009-03-30 22:01 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.4.4 4.3.0
Known to fail: 4.0.4 4.1.3 4.2.3 4.2.5
Last reconfirmed: 2007-11-02 21:02:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paolo Carlini 2007-06-08 15:30:12 UTC
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...
Comment 1 Paolo Carlini 2007-06-08 16:53:14 UTC
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)
Comment 2 Tom Tromey 2007-11-02 20:43:14 UTC
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.
Comment 3 Paolo Carlini 2007-11-02 20:53:38 UTC
Thanks Tom, your help is appreciated. Note we have also c++/32368: shall we recategorize both as middle-end bugs then?
Comment 4 Tom Tromey 2007-11-02 21:02:27 UTC
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.
Comment 5 Paolo Carlini 2007-11-02 21:12:46 UTC
Cool. Then maybe recategorizing is now just a waste of time ;)
Comment 6 Tom Tromey 2007-11-06 15:57:16 UTC
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

Comment 7 Tom Tromey 2007-11-06 16:01:23 UTC
Fixed on trunk.
Comment 8 Paolo Carlini 2007-11-06 17:24:36 UTC
Thanks a lot, Tom!
Comment 9 Joseph S. Myers 2008-05-19 20:23:08 UTC
4.2.4 is being released, changing milestones to 4.2.5.
Comment 10 Joseph S. Myers 2009-03-30 22:01:51 UTC
Closing 4.2 branch, fixed in 4.3.