[PATCH 2/2] (header usage fix) include c++ headers in system.h

2017-08-06 Thread Ryan Mounce
2017-08-05  Ryan Mounce  

cherry picked from trunk r235362
2016-04-22  Szabolcs Nagy  

* system.h (list, map, set, vector): Include conditionally.
* auto-profile.c (INCLUDE_MAP, INCLUDE_SET): Define.
* graphite-isl-ast-to-gimple.c (INCLUDE_MAP): Define.
* ipa-icf.c (INCLUDE_LIST): Define.
* ipa-icf-gimple.c (INCLUDE_LIST): Define.
* config/sh/sh.c (INCLUDE_VECTOR): Define.
* config/sh/sh_treg_combine.cc (INCLUDE_ALGORITHM): Define.
(INCLUDE_LIST, INCLUDE_VECTOR): Define.
* fortran/trans-common.c (INCLUDE_MAP): Define.
---
 gcc/ChangeLog| 15 +++
 gcc/auto-profile.c   |  5 ++---
 gcc/config/sh/sh.c   |  2 +-
 gcc/config/sh/sh_treg_combine.cc |  7 +++
 gcc/fortran/trans-common.c   |  2 +-
 gcc/graphite-isl-ast-to-gimple.c |  2 +-
 gcc/ipa-icf-gimple.c |  2 +-
 gcc/ipa-icf.c|  2 +-
 gcc/system.h | 12 
 9 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f3280917ad8..d40ff4652af 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -3,6 +3,21 @@
Backport from mainline
2016-04-22  Szabolcs Nagy  
 
+   * system.h (list, map, set, vector): Include conditionally.
+   * auto-profile.c (INCLUDE_MAP, INCLUDE_SET): Define.
+   * graphite-isl-ast-to-gimple.c (INCLUDE_MAP): Define.
+   * ipa-icf.c (INCLUDE_LIST): Define.
+   * ipa-icf-gimple.c (INCLUDE_LIST): Define.
+   * config/sh/sh.c (INCLUDE_VECTOR): Define.
+   * config/sh/sh_treg_combine.cc (INCLUDE_ALGORITHM): Define.
+   (INCLUDE_LIST, INCLUDE_VECTOR): Define.
+   * fortran/trans-common.c (INCLUDE_MAP): Define.
+
+2017-08-05  Ryan Mounce  
+
+   Backport from mainline
+   2016-04-22  Szabolcs Nagy  
+
* auto-profile.c: Remove  include.
* diagnostic.c: Remove  include.
* genmatch.c: Likewise.
diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index a5e7225e338..7bbd8140c45 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -19,11 +19,10 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+#define INCLUDE_MAP
+#define INCLUDE_SET
 #include "system.h"
 
-#include 
-#include 
-
 #include "coretypes.h"
 #include "hash-set.h"
 #include "machmode.h"
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 3bb81fc1cd8..9db77530c1f 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -20,9 +20,9 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include 
-#include 
 
 #include "config.h"
+#define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
diff --git a/gcc/config/sh/sh_treg_combine.cc b/gcc/config/sh/sh_treg_combine.cc
index e4f3581099c..ea20c3f407e 100644
--- a/gcc/config/sh/sh_treg_combine.cc
+++ b/gcc/config/sh/sh_treg_combine.cc
@@ -19,6 +19,9 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+#define INCLUDE_ALGORITHM
+#define INCLUDE_LIST
+#define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
 #include "machmode.h"
@@ -65,10 +68,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "stmt.h"
 #include "expr.h"
 
-#include 
-#include 
-#include 
-
 /*
 This pass tries to optimize for example this:
mov.l   @(4,r4),r1
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c
index f393419db5e..1ee744190d1 100644
--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -92,8 +92,8 @@ along with GCC; see the file COPYING3.  If not see
is examined for still-unused equivalence conditions.  We create a
block for each merged equivalence list.  */
 
-#include 
 #include "config.h"
+#define INCLUDE_MAP
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index a83a85dbabc..3216460b625 100644
--- a/gcc/graphite-isl-ast-to-gimple.c
+++ b/gcc/graphite-isl-ast-to-gimple.c
@@ -38,6 +38,7 @@ extern "C" {
 #endif
 #endif
 
+#define INCLUDE_MAP
 #include "system.h"
 #include "coretypes.h"
 #include "hash-set.h"
@@ -75,7 +76,6 @@ extern "C" {
 #include "tree-scalar-evolution.h"
 #include "gimple-ssa.h"
 #include "tree-into-ssa.h"
-#include 
 
 #ifdef HAVE_isl
 #include "graphite-poly.h"
diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index 9efdea465c2..144462fce11 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+#define INCLUDE_LIST
 #include "system.h"
 #include "coretypes.h"
 #include "hash-set.h"
@@ -74,7 +75,6 @@ 

Re: [PATCH 2/2] (header usage fix) include c++ headers in system.h

2016-04-22 Thread Pedro Alves
On 04/22/2016 11:02 AM, Szabolcs Nagy wrote:
> Some gcc source files include standard headers after
> "system.h" but those headers may declare and use poisoned
> symbols, 

Couldn't gcc simply allow use of poisoned symbols in
system headers?

It sounds like it'd avoid these odd contortions.

> they also cannot be included before "system.h"
> because they might depend on macro definitions from there,
> so they must be included in system.h.

Thanks,
Pedro Alves



Re: [PATCH 2/2] (header usage fix) include c++ headers in system.h

2016-04-22 Thread David Edelsohn
On Fri, Apr 22, 2016 at 6:02 AM, Szabolcs Nagy  wrote:
> Some gcc source files include standard headers after
> "system.h" but those headers may declare and use poisoned
> symbols, they also cannot be included before "system.h"
> because they might depend on macro definitions from there,
> so they must be included in system.h.
>
> This patch fixes the use of , , , 
> and  headers, by using appropriate
> INCLUDE_{LIST, MAP, SET, VECTOR, ALGORITHM} macros.
> (Note that there are some other system header uses which
> did not get fixed.)
>
> Build tested on aarch64-*-gnu, sh-*-musl, x86_64-*-musl and
> bootstrapped x86_64-*-gnu (together with PATCH 1/2).
>
> is this ok for AIX?

It should be okay on AIX.

> OK for trunk?
>
> This would be nice to fix in gcc-6 too, because at least
> with musl libc the bootstrap is broken.
>
> gcc/ChangeLog:
>
> 2016-04-22  Szabolcs Nagy  
>
> * system.h (list, map, set, vector): Include conditionally.
> * auto-profile.c (INCLUDE_MAP, INCLUDE_SET): Define.
> * graphite-isl-ast-to-gimple.c (INCLUDE_MAP): Define.
> * ipa-icf.c (INCLUDE_LIST): Define.
> * config/aarch64/cortex-a57-fma-steering.c (INCLUDE_LIST): Define.
> * config/sh/sh.c (INCLUDE_VECTOR): Define.
> * config/sh/sh_treg_combine.cc (INCLUDE_ALGORITHM): Define.
> (INCLUDE_LIST, INCLUDE_VECTOR): Define.
> * cp/logic.cc (INCLUDE_LIST): Define.
> * fortran/trans-common.c (INCLUDE_MAP): Define.


Re: [PATCH 2/2] (header usage fix) include c++ headers in system.h

2016-04-22 Thread Richard Biener
On Fri, Apr 22, 2016 at 12:02 PM, Szabolcs Nagy  wrote:
> Some gcc source files include standard headers after
> "system.h" but those headers may declare and use poisoned
> symbols, they also cannot be included before "system.h"
> because they might depend on macro definitions from there,
> so they must be included in system.h.
>
> This patch fixes the use of , , , 
> and  headers, by using appropriate
> INCLUDE_{LIST, MAP, SET, VECTOR, ALGORITHM} macros.
> (Note that there are some other system header uses which
> did not get fixed.)
>
> Build tested on aarch64-*-gnu, sh-*-musl, x86_64-*-musl and
> bootstrapped x86_64-*-gnu (together with PATCH 1/2).
>
> is this ok for AIX?
> OK for trunk?

Ok for trunk and gcc-6.

Thanks,
Richard.

> This would be nice to fix in gcc-6 too, because at least
> with musl libc the bootstrap is broken.
>
> gcc/ChangeLog:
>
> 2016-04-22  Szabolcs Nagy  
>
> * system.h (list, map, set, vector): Include conditionally.
> * auto-profile.c (INCLUDE_MAP, INCLUDE_SET): Define.
> * graphite-isl-ast-to-gimple.c (INCLUDE_MAP): Define.
> * ipa-icf.c (INCLUDE_LIST): Define.
> * config/aarch64/cortex-a57-fma-steering.c (INCLUDE_LIST): Define.
> * config/sh/sh.c (INCLUDE_VECTOR): Define.
> * config/sh/sh_treg_combine.cc (INCLUDE_ALGORITHM): Define.
> (INCLUDE_LIST, INCLUDE_VECTOR): Define.
> * cp/logic.cc (INCLUDE_LIST): Define.
> * fortran/trans-common.c (INCLUDE_MAP): Define.


Re: [PATCH 2/2] (header usage fix) include c++ headers in system.h

2016-04-22 Thread James Greenhalgh
On Fri, Apr 22, 2016 at 11:02:48AM +0100, Szabolcs Nagy wrote:
> Some gcc source files include standard headers after
> "system.h" but those headers may declare and use poisoned
> symbols, they also cannot be included before "system.h"
> because they might depend on macro definitions from there,
> so they must be included in system.h.
> 
> This patch fixes the use of , , , 
> and  headers, by using appropriate
> INCLUDE_{LIST, MAP, SET, VECTOR, ALGORITHM} macros.
> (Note that there are some other system header uses which
> did not get fixed.)
> 
> Build tested on aarch64-*-gnu, sh-*-musl, x86_64-*-musl and
> bootstrapped x86_64-*-gnu (together with PATCH 1/2).
> 
> is this ok for AIX?
> OK for trunk?

The AArch64 part of this is OK.

Thanks,
James



[PATCH 2/2] (header usage fix) include c++ headers in system.h

2016-04-22 Thread Szabolcs Nagy
Some gcc source files include standard headers after
"system.h" but those headers may declare and use poisoned
symbols, they also cannot be included before "system.h"
because they might depend on macro definitions from there,
so they must be included in system.h.

This patch fixes the use of , , , 
and  headers, by using appropriate
INCLUDE_{LIST, MAP, SET, VECTOR, ALGORITHM} macros.
(Note that there are some other system header uses which
did not get fixed.)

Build tested on aarch64-*-gnu, sh-*-musl, x86_64-*-musl and
bootstrapped x86_64-*-gnu (together with PATCH 1/2).

is this ok for AIX?
OK for trunk?

This would be nice to fix in gcc-6 too, because at least
with musl libc the bootstrap is broken.

gcc/ChangeLog:

2016-04-22  Szabolcs Nagy  

* system.h (list, map, set, vector): Include conditionally.
* auto-profile.c (INCLUDE_MAP, INCLUDE_SET): Define.
* graphite-isl-ast-to-gimple.c (INCLUDE_MAP): Define.
* ipa-icf.c (INCLUDE_LIST): Define.
* config/aarch64/cortex-a57-fma-steering.c (INCLUDE_LIST): Define.
* config/sh/sh.c (INCLUDE_VECTOR): Define.
* config/sh/sh_treg_combine.cc (INCLUDE_ALGORITHM): Define.
(INCLUDE_LIST, INCLUDE_VECTOR): Define.
* cp/logic.cc (INCLUDE_LIST): Define.
* fortran/trans-common.c (INCLUDE_MAP): Define.
diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index 0c726bd..cd82ab4 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -19,6 +19,8 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+#define INCLUDE_MAP
+#define INCLUDE_SET
 #include "system.h"
 #include "coretypes.h"
 #include "backend.h"
@@ -31,10 +33,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "cgraph.h"
 #include "gcov-io.h"
 #include "diagnostic-core.h"
-
-#include 
-#include 
-
 #include "profile.h"
 #include "langhooks.h"
 #include "cfgloop.h"
diff --git a/gcc/config/aarch64/cortex-a57-fma-steering.c b/gcc/config/aarch64/cortex-a57-fma-steering.c
index 21159fe..1bf804b 100644
--- a/gcc/config/aarch64/cortex-a57-fma-steering.c
+++ b/gcc/config/aarch64/cortex-a57-fma-steering.c
@@ -19,6 +19,7 @@
.  */
 
 #include "config.h"
+#define INCLUDE_LIST
 #include "system.h"
 #include "coretypes.h"
 #include "backend.h"
@@ -37,8 +38,6 @@
 #include "cortex-a57-fma-steering.h"
 #include "aarch64-protos.h"
 
-#include 
-
 /* For better performance, the destination of FMADD/FMSUB instructions should
have the same parity as their accumulator register if the accumulator
contains the result of a previous FMUL or FMADD/FMSUB instruction if
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 8c8fe3c..b18e59b 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -20,9 +20,9 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include 
-#include 
 
 #include "config.h"
+#define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
 #include "backend.h"
diff --git a/gcc/config/sh/sh_treg_combine.cc b/gcc/config/sh/sh_treg_combine.cc
index bc1ee0e..4d40715 100644
--- a/gcc/config/sh/sh_treg_combine.cc
+++ b/gcc/config/sh/sh_treg_combine.cc
@@ -19,6 +19,9 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+#define INCLUDE_ALGORITHM
+#define INCLUDE_LIST
+#define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
 #include "backend.h"
@@ -32,10 +35,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-pass.h"
 #include "expr.h"
 
-#include 
-#include 
-#include 
-
 /*
 This pass tries to optimize for example this:
 	mov.l	@(4,r4),r1
diff --git a/gcc/cp/logic.cc b/gcc/cp/logic.cc
index e4967bb..c12c381 100644
--- a/gcc/cp/logic.cc
+++ b/gcc/cp/logic.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 .  */
 
 #include "config.h"
+#define INCLUDE_LIST
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
@@ -45,8 +46,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "toplev.h"
 #include "type-utils.h"
 
-#include 
-
 namespace {
 
 // Helper algorithms
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c
index 44787ae..4fdccc9 100644
--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -93,6 +93,7 @@ along with GCC; see the file COPYING3.  If not see
block for each merged equivalence list.  */
 
 #include "config.h"
+#define INCLUDE_MAP
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
@@ -100,9 +101,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "gfortran.h"
 #include "trans.h"
 #include "stringpool.h"
-
-#include 
-
 #include "fold-const.h"
 #include "stor-layout.h"
 #include "varasm.h"
diff --git a/gcc/graphite-isl-ast-to-gimple.c b/gcc/graphite-isl-ast-to-gimple.c
index 88609c0..049a4c5 100644
---