diff mbox

[1/2] (header usage fix) remove unused system header includes

Message ID 5719F6A0.6050700@arm.com
State New
Headers show

Commit Message

Szabolcs Nagy April 22, 2016, 10:02 a.m. UTC
These headers include "system.h" which already includes
<new> and <string.h> so including them after "system.h"
is a noop and including them before may cause problems
if they depend on gcc macros from system.h.

ipa-icf-gimple.c includes <list> after system.h which
poisons various libc symbols which may cause problems
and it is not used at all.

Tested together with PATCH 2/2.

OK for trunk?

gcc/ChangeLog:

2016-04-22  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* auto-profile.c: Remove <string.h> include.
	* ipa-icf-gimple.c: Remove <list> include.
	* diagnostic.c: Remove <new> include.
	* genmatch.c: Likewise.
	* pretty-print.c: Likewise.
	* toplev.c: Likewise
	* c/c-objc-common.c: Likewise.
	* cp/error.c: Likewise.
	* fortran/error.c: Likewise.

Comments

Richard Biener April 22, 2016, 10:17 a.m. UTC | #1
On Fri, Apr 22, 2016 at 12:02 PM, Szabolcs Nagy <szabolcs.nagy@arm.com> wrote:
> These headers include "system.h" which already includes
> <new> and <string.h> so including them after "system.h"
> is a noop and including them before may cause problems
> if they depend on gcc macros from system.h.
>
> ipa-icf-gimple.c includes <list> after system.h which
> poisons various libc symbols which may cause problems
> and it is not used at all.
>
> Tested together with PATCH 2/2.
>
> OK for trunk?

Ok.

Thanks,
Richard.

> gcc/ChangeLog:
>
> 2016-04-22  Szabolcs Nagy  <szabolcs.nagy@arm.com>
>
>         * auto-profile.c: Remove <string.h> include.
>         * ipa-icf-gimple.c: Remove <list> include.
>         * diagnostic.c: Remove <new> include.
>         * genmatch.c: Likewise.
>         * pretty-print.c: Likewise.
>         * toplev.c: Likewise
>         * c/c-objc-common.c: Likewise.
>         * cp/error.c: Likewise.
>         * fortran/error.c: Likewise.
diff mbox

Patch

diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index 5c0640a..0c726bd 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -32,7 +32,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "gcov-io.h"
 #include "diagnostic-core.h"
 
-#include <string.h>
 #include <map>
 #include <set>
 
diff --git a/gcc/c/c-objc-common.c b/gcc/c/c-objc-common.c
index 18247af..20dc024 100644
--- a/gcc/c/c-objc-common.c
+++ b/gcc/c/c-objc-common.c
@@ -27,8 +27,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "langhooks.h"
 #include "c-objc-common.h"
 
-#include <new>                          // For placement new.
-
 static bool c_tree_printer (pretty_printer *, text_info *, const char *,
 			    int, bool, bool, bool);
 
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index aa5fd41..7d70f89 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -31,8 +31,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "ubsan.h"
 #include "internal-fn.h"
 
-#include <new>                    // For placement-new.
-
 #define pp_separate_with_comma(PP) pp_cxx_separate_with (PP, ',')
 #define pp_separate_with_semicolon(PP) pp_cxx_separate_with (PP, ';')
 
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 6a679cb..8106172 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -40,8 +40,6 @@  along with GCC; see the file COPYING3.  If not see
 # include <sys/ioctl.h>
 #endif
 
-#include <new>                     // For placement new.
-
 #define pedantic_warning_kind(DC)			\
   ((DC)->pedantic_errors ? DK_ERROR : DK_WARNING)
 #define permissive_error_kind(DC) ((DC)->permissive ? DK_WARNING : DK_ERROR)
diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c
index 003702b..6cfe019 100644
--- a/gcc/fortran/error.c
+++ b/gcc/fortran/error.c
@@ -34,8 +34,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "diagnostic-color.h"
 #include "tree-diagnostic.h" /* tree_diagnostics_defaults */
 
-#include <new> /* For placement-new */
-
 static int suppress_errors = 0;
 
 static bool warnings_not_errors = false;
diff --git a/gcc/genmatch.c b/gcc/genmatch.c
index 1f5f45c..ce964fa 100644
--- a/gcc/genmatch.c
+++ b/gcc/genmatch.c
@@ -22,7 +22,6 @@  along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "bconfig.h"
-#include <new>
 #include "system.h"
 #include "coretypes.h"
 #include <cpplib.h>
diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index 69db0d3..9e3c862 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -35,7 +35,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "fold-const.h"
 #include "gimple-iterator.h"
 #include "ipa-utils.h"
-#include <list>
 #include "tree-eh.h"
 #include "builtins.h"
 
diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c
index acb89e6..49e1cb9 100644
--- a/gcc/pretty-print.c
+++ b/gcc/pretty-print.c
@@ -25,8 +25,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "pretty-print.h"
 #include "diagnostic-color.h"
 
-#include <new>                    // For placement-new.
-
 #if HAVE_ICONV
 #include <iconv.h>
 #endif
diff --git a/gcc/toplev.c b/gcc/toplev.c
index c480bfc..8979d26 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -87,8 +87,6 @@  along with GCC; see the file COPYING3.  If not see
 #include "xcoffout.h"		/* Needed for external data declarations. */
 #endif
 
-#include <new>
-
 static void general_init (const char *, bool);
 static void do_compile ();
 static void process_options (void);