coretypes.h (const_bitmap, [...]): New.
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>
Wed, 25 Jul 2007 18:00:08 +0000 (18:00 +0000)
committerKaveh Ghazi <ghazi@gcc.gnu.org>
Wed, 25 Jul 2007 18:00:08 +0000 (18:00 +0000)
* coretypes.h (const_bitmap, const_rtx, const_rtvec, const_tree):
New.

* rtl.h (RTL_CHECK1, RTL_CHECK2, RTL_CHECKC1, RTL_CHECKC2,
RTVEC_ELT, XWINT, XCWINT, XCMWINT, XCNMPRV, BLOCK_SYMBOL_CHECK,
RTL_FLAG_CHECK1, RTL_FLAG_CHECK2, RTL_FLAG_CHECK3,
RTL_FLAG_CHECK4, RTL_FLAG_CHECK5, RTL_FLAG_CHECK6,
RTL_FLAG_CHECK7, RTL_FLAG_CHECK8, LABEL_KIND, SET_LABEL_KIND):
Preserve const-ness of parameters through use of __typeof(),
also constify and tidy.

* tree.h (TREE_CHECK, TREE_NOT_CHECK, TREE_CHECK2,
TREE_NOT_CHECK2, TREE_CHECK3, TREE_NOT_CHECK3, TREE_CHECK4,
NON_TREE_CHECK4, TREE_CHECK5, TREE_NOT_CHECK5,
CONTAINS_STRUCT_CHECK, TREE_CLASS_CHECK, TREE_RANGE_CHECK,
OMP_CLAUSE_SUBCODE_CHECK, OMP_CLAUSE_RANGE_CHECK, EXPR_CHECK,
GIMPLE_STMT_CHECK, NON_TYPE_CHECK, TREE_VEC_ELT_CHECK,
PHI_NODE_ELT_CHECK, OMP_CLAUSE_ELT_CHECK, TREE_OPERAND_CHECK,
TREE_OPERAND_CHECK_CODE, GIMPLE_STMT_OPERAND_CHECK,
TREE_RTL_OPERAND_CHECK, TREE_CHAIN, TREE_TYPE): Likewise.

From-SVN: r126918

gcc/ChangeLog
gcc/coretypes.h
gcc/rtl.h
gcc/tree.h

index e891974313a66bd24d2585823f5d5c8dd34fbd38..aee62339d470e752073f743dfb5357c98e8cd8c2 100644 (file)
@@ -1,3 +1,26 @@
+2007-07-25  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * coretypes.h (const_bitmap, const_rtx, const_rtvec, const_tree):
+       New.
+       
+       * rtl.h (RTL_CHECK1, RTL_CHECK2, RTL_CHECKC1, RTL_CHECKC2,
+       RTVEC_ELT, XWINT, XCWINT, XCMWINT, XCNMPRV, BLOCK_SYMBOL_CHECK,
+       RTL_FLAG_CHECK1, RTL_FLAG_CHECK2, RTL_FLAG_CHECK3,
+       RTL_FLAG_CHECK4, RTL_FLAG_CHECK5, RTL_FLAG_CHECK6,
+       RTL_FLAG_CHECK7, RTL_FLAG_CHECK8, LABEL_KIND, SET_LABEL_KIND):
+       Preserve const-ness of parameters through use of __typeof(),
+       also constify and tidy.
+       
+       * tree.h (TREE_CHECK, TREE_NOT_CHECK, TREE_CHECK2,
+       TREE_NOT_CHECK2, TREE_CHECK3, TREE_NOT_CHECK3, TREE_CHECK4,
+       NON_TREE_CHECK4, TREE_CHECK5, TREE_NOT_CHECK5,
+       CONTAINS_STRUCT_CHECK, TREE_CLASS_CHECK, TREE_RANGE_CHECK,
+       OMP_CLAUSE_SUBCODE_CHECK, OMP_CLAUSE_RANGE_CHECK, EXPR_CHECK,
+       GIMPLE_STMT_CHECK, NON_TYPE_CHECK, TREE_VEC_ELT_CHECK,
+       PHI_NODE_ELT_CHECK, OMP_CLAUSE_ELT_CHECK, TREE_OPERAND_CHECK,
+       TREE_OPERAND_CHECK_CODE, GIMPLE_STMT_OPERAND_CHECK,
+       TREE_RTL_OPERAND_CHECK, TREE_CHAIN, TREE_TYPE): Likewise.
+
 2007-07-25  Julian Brown  <julian@codesourcery.com>
            Mark Shinwell  <shinwell@codesourcery.com>
 
index 3f0c58a7e06ed09eea4a50d4ad7eca3705841dea..ea116f60f9f689b06f1b68d5bf1c53ee13fd93ea 100644 (file)
@@ -39,12 +39,16 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 
 struct bitmap_head_def;
 typedef struct bitmap_head_def *bitmap;
+typedef const struct bitmap_head_def *const_bitmap;
 struct rtx_def;
 typedef struct rtx_def *rtx;
+typedef const struct rtx_def *const_rtx;
 struct rtvec_def;
 typedef struct rtvec_def *rtvec;
+typedef const struct rtvec_def *const_rtvec;
 union tree_node;
 typedef union tree_node *tree;
+typedef const union tree_node *const_tree;
 union section;
 typedef union section section;
 
@@ -78,8 +82,11 @@ struct _dont_use_rtx_here_;
 struct _dont_use_rtvec_here_;
 union _dont_use_tree_here_;
 #define rtx struct _dont_use_rtx_here_ *
+#define const_rtx struct _dont_use_rtx_here_ *
 #define rtvec struct _dont_use_rtvec_here *
+#define const_rtvec struct _dont_use_rtvec_here *
 #define tree union _dont_use_tree_here_ *
+#define const_tree union _dont_use_tree_here_ *
 
 #endif
 
index b658ff0d6aeea22b87558913e4c9648b242db240..446e9ab8adc55aa34abb5a5d6cb5be20c35a0072 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -454,7 +454,7 @@ struct rtvec_def GTY(()) {
 /* The bit with a star outside the statement expr and an & inside is
    so that N can be evaluated only once.  */
 #define RTL_CHECK1(RTX, N, C1) __extension__                           \
-(*({ rtx const _rtx = (RTX); const int _n = (N);                       \
+(*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N);            \
      const enum rtx_code _code = GET_CODE (_rtx);                      \
      if (_n < 0 || _n >= GET_RTX_LENGTH (_code))                       \
        rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__,          \
@@ -465,7 +465,7 @@ struct rtvec_def GTY(()) {
      &_rtx->u.fld[_n]; }))
 
 #define RTL_CHECK2(RTX, N, C1, C2) __extension__                       \
-(*({ rtx const _rtx = (RTX); const int _n = (N);                       \
+(*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N);            \
      const enum rtx_code _code = GET_CODE (_rtx);                      \
      if (_n < 0 || _n >= GET_RTX_LENGTH (_code))                       \
        rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__,          \
@@ -477,14 +477,14 @@ struct rtvec_def GTY(()) {
      &_rtx->u.fld[_n]; }))
 
 #define RTL_CHECKC1(RTX, N, C) __extension__                           \
-(*({ rtx const _rtx = (RTX); const int _n = (N);                       \
+(*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N);            \
      if (GET_CODE (_rtx) != (C))                                       \
        rtl_check_failed_code1 (_rtx, (C), __FILE__, __LINE__,          \
                               __FUNCTION__);                           \
      &_rtx->u.fld[_n]; }))
 
 #define RTL_CHECKC2(RTX, N, C1, C2) __extension__                      \
-(*({ rtx const _rtx = (RTX); const int _n = (N);                       \
+(*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N);            \
      const enum rtx_code _code = GET_CODE (_rtx);                      \
      if (_code != (C1) && _code != (C2))                               \
        rtl_check_failed_code2 (_rtx, (C1), (C2), __FILE__, __LINE__,   \
@@ -492,14 +492,14 @@ struct rtvec_def GTY(()) {
      &_rtx->u.fld[_n]; }))
 
 #define RTVEC_ELT(RTVEC, I) __extension__                              \
-(*({ rtvec const _rtvec = (RTVEC); const int _i = (I);                 \
+(*({ __typeof (RTVEC) const _rtvec = (RTVEC); const int _i = (I);      \
      if (_i < 0 || _i >= GET_NUM_ELEM (_rtvec))                                \
        rtvec_check_failed_bounds (_rtvec, _i, __FILE__, __LINE__,      \
                                  __FUNCTION__);                        \
      &_rtvec->elem[_i]; }))
 
 #define XWINT(RTX, N) __extension__                                    \
-(*({ rtx const _rtx = (RTX); const int _n = (N);                       \
+(*({ __typeof (RTX) const _rtx = (RTX); const int _n = (N);            \
      const enum rtx_code _code = GET_CODE (_rtx);                      \
      if (_n < 0 || _n >= GET_RTX_LENGTH (_code))                       \
        rtl_check_failed_bounds (_rtx, _n, __FILE__, __LINE__,          \
@@ -510,29 +510,29 @@ struct rtvec_def GTY(()) {
      &_rtx->u.hwint[_n]; }))
 
 #define XCWINT(RTX, N, C) __extension__                                        \
-(*({ rtx const _rtx = (RTX);                                           \
+(*({ __typeof (RTX) const _rtx = (RTX);                                        \
      if (GET_CODE (_rtx) != (C))                                       \
        rtl_check_failed_code1 (_rtx, (C), __FILE__, __LINE__,          \
                               __FUNCTION__);                           \
      &_rtx->u.hwint[N]; }))
 
 #define XCMWINT(RTX, N, C, M) __extension__                            \
-(*({ rtx const _rtx = (RTX);                                           \
+(*({ __typeof (RTX) const _rtx = (RTX);                                        \
      if (GET_CODE (_rtx) != (C) || GET_MODE (_rtx) != (M))             \
        rtl_check_failed_code_mode (_rtx, (C), (M), false, __FILE__,    \
                                   __LINE__, __FUNCTION__);             \
      &_rtx->u.hwint[N]; }))
 
 #define XCNMPRV(RTX, C, M) __extension__                               \
-({ rtx const _rtx = (RTX);                                             \
+({ __typeof (RTX) const _rtx = (RTX);                                  \
    if (GET_CODE (_rtx) != (C) || GET_MODE (_rtx) == (M))               \
      rtl_check_failed_code_mode (_rtx, (C), (M), true, __FILE__,       \
                                 __LINE__, __FUNCTION__);               \
    &_rtx->u.rv; })
 
 #define BLOCK_SYMBOL_CHECK(RTX) __extension__                          \
-({ rtx const _symbol = (RTX);                                          \
-   unsigned int flags = RTL_CHECKC1 (_symbol, 1, SYMBOL_REF).rt_int;   \
+({ __typeof (RTX) const _symbol = (RTX);                               \
+   const unsigned int flags = RTL_CHECKC1 (_symbol, 1, SYMBOL_REF).rt_int; \
    if ((flags & SYMBOL_FLAG_HAS_BLOCK_INFO) == 0)                      \
      rtl_check_failed_block_symbol (__FILE__, __LINE__,                        \
                                    __FUNCTION__);                      \
@@ -585,21 +585,21 @@ extern void rtvec_check_failed_bounds (rtvec, int, const char *, int,
 
 #if defined ENABLE_RTL_FLAG_CHECKING && (GCC_VERSION >= 2007)
 #define RTL_FLAG_CHECK1(NAME, RTX, C1) __extension__                   \
-({ rtx const _rtx = (RTX);                                             \
+({ __typeof (RTX) const _rtx = (RTX);                                  \
    if (GET_CODE(_rtx) != C1)                                           \
      rtl_check_failed_flag  (NAME, _rtx, __FILE__, __LINE__,           \
                             __FUNCTION__);                             \
    _rtx; })
 
 #define RTL_FLAG_CHECK2(NAME, RTX, C1, C2) __extension__               \
-({ rtx const _rtx = (RTX);                                             \
+({ __typeof (RTX) const _rtx = (RTX);                                  \
    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2)                   \
      rtl_check_failed_flag  (NAME,_rtx, __FILE__, __LINE__,            \
                              __FUNCTION__);                            \
    _rtx; })
 
 #define RTL_FLAG_CHECK3(NAME, RTX, C1, C2, C3) __extension__           \
-({ rtx const _rtx = (RTX);                                             \
+({ __typeof (RTX) const _rtx = (RTX);                                  \
    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2                    \
        && GET_CODE(_rtx) != C3)                                                \
      rtl_check_failed_flag  (NAME, _rtx, __FILE__, __LINE__,           \
@@ -607,7 +607,7 @@ extern void rtvec_check_failed_bounds (rtvec, int, const char *, int,
    _rtx; })
 
 #define RTL_FLAG_CHECK4(NAME, RTX, C1, C2, C3, C4) __extension__       \
-({ rtx const _rtx = (RTX);                                             \
+({ __typeof (RTX) const _rtx = (RTX);                                  \
    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2                    \
        && GET_CODE(_rtx) != C3 && GET_CODE(_rtx) != C4)                        \
      rtl_check_failed_flag  (NAME, _rtx, __FILE__, __LINE__,           \
@@ -615,7 +615,7 @@ extern void rtvec_check_failed_bounds (rtvec, int, const char *, int,
    _rtx; })
 
 #define RTL_FLAG_CHECK5(NAME, RTX, C1, C2, C3, C4, C5) __extension__   \
-({ rtx const _rtx = (RTX);                                             \
+({ __typeof (RTX) const _rtx = (RTX);                                  \
    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2                    \
        && GET_CODE(_rtx) != C3 && GET_CODE(_rtx) != C4                 \
        && GET_CODE(_rtx) != C5)                                                \
@@ -625,7 +625,7 @@ extern void rtvec_check_failed_bounds (rtvec, int, const char *, int,
 
 #define RTL_FLAG_CHECK6(NAME, RTX, C1, C2, C3, C4, C5, C6)             \
   __extension__                                                                \
-({ rtx const _rtx = (RTX);                                             \
+({ __typeof (RTX) const _rtx = (RTX);                                  \
    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2                    \
        && GET_CODE(_rtx) != C3 && GET_CODE(_rtx) != C4                 \
        && GET_CODE(_rtx) != C5 && GET_CODE(_rtx) != C6)                        \
@@ -635,7 +635,7 @@ extern void rtvec_check_failed_bounds (rtvec, int, const char *, int,
 
 #define RTL_FLAG_CHECK7(NAME, RTX, C1, C2, C3, C4, C5, C6, C7)         \
   __extension__                                                                \
-({ rtx const _rtx = (RTX);                                             \
+({ __typeof (RTX) const _rtx = (RTX);                                  \
    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2                    \
        && GET_CODE(_rtx) != C3 && GET_CODE(_rtx) != C4                 \
        && GET_CODE(_rtx) != C5 && GET_CODE(_rtx) != C6                 \
@@ -646,7 +646,7 @@ extern void rtvec_check_failed_bounds (rtvec, int, const char *, int,
 
 #define RTL_FLAG_CHECK8(NAME, RTX, C1, C2, C3, C4, C5, C6, C7, C8)     \
   __extension__                                                                \
-({ rtx const _rtx = (RTX);                                             \
+({ __typeof (RTX) const _rtx = (RTX);                                  \
    if (GET_CODE(_rtx) != C1 && GET_CODE(_rtx) != C2                    \
        && GET_CODE(_rtx) != C3 && GET_CODE(_rtx) != C4                 \
        && GET_CODE(_rtx) != C5 && GET_CODE(_rtx) != C6                 \
@@ -910,7 +910,7 @@ enum label_kind
 
 /* Retrieve the kind of LABEL.  */
 #define LABEL_KIND(LABEL) __extension__                                        \
-({ rtx const _label = (LABEL);                                         \
+({ __typeof (LABEL) const _label = (LABEL);                                    \
    if (GET_CODE (_label) != CODE_LABEL)                                        \
      rtl_check_failed_flag ("LABEL_KIND", _label, __FILE__, __LINE__,  \
                            __FUNCTION__);                              \
@@ -918,8 +918,8 @@ enum label_kind
 
 /* Set the kind of LABEL.  */
 #define SET_LABEL_KIND(LABEL, KIND) do {                               \
-   rtx _label = (LABEL);                                               \
-   unsigned int _kind = (KIND);                                                \
+   rtx const _label = (LABEL);                                         \
+   const unsigned int _kind = (KIND);                                  \
    if (GET_CODE (_label) != CODE_LABEL)                                        \
      rtl_check_failed_flag ("SET_LABEL_KIND", _label, __FILE__, __LINE__, \
                            __FUNCTION__);                              \
@@ -935,8 +935,8 @@ enum label_kind
 
 /* Set the kind of LABEL.  */
 #define SET_LABEL_KIND(LABEL, KIND) do {                               \
-   rtx _label = (LABEL);                                               \
-   unsigned int _kind = (KIND);                                                \
+   rtx const _label = (LABEL);                                         \
+   const unsigned int _kind = (KIND);                                  \
    _label->jump = ((_kind >> 1) & 1);                                  \
    _label->call = (_kind & 1);                                         \
 } while (0)
index 82e9933592a0d8e29bae9cfc24f5c051db68af2b..7916b975fbbd8f1e2888ebe91b18e3b7907c4d9a 100644 (file)
@@ -601,21 +601,21 @@ enum tree_node_structure_enum {
 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
 
 #define TREE_CHECK(T, CODE) __extension__                              \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) != (CODE))                                     \
       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,        \
                         (CODE), 0);                                    \
     __t; })
 
 #define TREE_NOT_CHECK(T, CODE) __extension__                          \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) == (CODE))                                     \
       tree_not_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,    \
                             (CODE), 0);                                \
     __t; })
 
 #define TREE_CHECK2(T, CODE1, CODE2) __extension__                     \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) != (CODE1)                                     \
        && TREE_CODE (__t) != (CODE2))                                  \
       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,                \
@@ -623,7 +623,7 @@ enum tree_node_structure_enum {
     __t; })
 
 #define TREE_NOT_CHECK2(T, CODE1, CODE2) __extension__                 \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) == (CODE1)                                     \
        || TREE_CODE (__t) == (CODE2))                                  \
       tree_not_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,    \
@@ -631,7 +631,7 @@ enum tree_node_structure_enum {
     __t; })
 
 #define TREE_CHECK3(T, CODE1, CODE2, CODE3) __extension__              \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) != (CODE1)                                     \
        && TREE_CODE (__t) != (CODE2)                                   \
        && TREE_CODE (__t) != (CODE3))                                  \
@@ -640,7 +640,7 @@ enum tree_node_structure_enum {
     __t; })
 
 #define TREE_NOT_CHECK3(T, CODE1, CODE2, CODE3) __extension__          \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) == (CODE1)                                     \
        || TREE_CODE (__t) == (CODE2)                                   \
        || TREE_CODE (__t) == (CODE3))                                  \
@@ -649,7 +649,7 @@ enum tree_node_structure_enum {
     __t; })
 
 #define TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) __extension__       \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) != (CODE1)                                     \
        && TREE_CODE (__t) != (CODE2)                                   \
        && TREE_CODE (__t) != (CODE3)                                   \
@@ -659,7 +659,7 @@ enum tree_node_structure_enum {
     __t; })
 
 #define NON_TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) __extension__   \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) == (CODE1)                                     \
        || TREE_CODE (__t) == (CODE2)                                   \
        || TREE_CODE (__t) == (CODE3)                                   \
@@ -669,7 +669,7 @@ enum tree_node_structure_enum {
     __t; })
 
 #define TREE_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) __extension__        \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) != (CODE1)                                     \
        && TREE_CODE (__t) != (CODE2)                                   \
        && TREE_CODE (__t) != (CODE3)                                   \
@@ -680,7 +680,7 @@ enum tree_node_structure_enum {
     __t; })
 
 #define TREE_NOT_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) __extension__ \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) == (CODE1)                                     \
        || TREE_CODE (__t) == (CODE2)                                   \
        || TREE_CODE (__t) == (CODE3)                                   \
@@ -691,28 +691,28 @@ enum tree_node_structure_enum {
     __t; })
 
 #define CONTAINS_STRUCT_CHECK(T, STRUCT) __extension__                 \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
   if (tree_contains_struct[TREE_CODE(__t)][(STRUCT)] != 1)             \
       tree_contains_struct_check_failed (__t, (STRUCT), __FILE__, __LINE__,    \
                               __FUNCTION__);                           \
     __t; })
 
 #define TREE_CLASS_CHECK(T, CLASS) __extension__                       \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE_CLASS (TREE_CODE(__t)) != (CLASS))                   \
       tree_class_check_failed (__t, (CLASS), __FILE__, __LINE__,       \
                               __FUNCTION__);                           \
     __t; })
 
 #define TREE_RANGE_CHECK(T, CODE1, CODE2) __extension__                        \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) < (CODE1) || TREE_CODE (__t) > (CODE2))                \
       tree_range_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,  \
                               (CODE1), (CODE2));                       \
     __t; })
 
 #define OMP_CLAUSE_SUBCODE_CHECK(T, CODE) __extension__                        \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) != OMP_CLAUSE)                                 \
       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,        \
                         OMP_CLAUSE, 0);                                \
@@ -722,7 +722,7 @@ enum tree_node_structure_enum {
     __t; })
 
 #define OMP_CLAUSE_RANGE_CHECK(T, CODE1, CODE2) __extension__          \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TREE_CODE (__t) != OMP_CLAUSE)                                 \
       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,        \
                         OMP_CLAUSE, 0);                                \
@@ -734,7 +734,7 @@ enum tree_node_structure_enum {
 
 /* These checks have to be special cased.  */
 #define EXPR_CHECK(T) __extension__                                    \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     char const __c = TREE_CODE_CLASS (TREE_CODE (__t));                        \
     if (!IS_EXPR_CODE_CLASS (__c))                                     \
       tree_class_check_failed (__t, tcc_expression, __FILE__, __LINE__,        \
@@ -742,7 +742,7 @@ enum tree_node_structure_enum {
     __t; })
 
 #define GIMPLE_STMT_CHECK(T) __extension__                             \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     char const __c = TREE_CODE_CLASS (TREE_CODE (__t));                        \
     if (!IS_GIMPLE_STMT_CODE_CLASS (__c))                              \
       tree_class_check_failed (__t, tcc_gimple_stmt, __FILE__, __LINE__,\
@@ -751,14 +751,14 @@ enum tree_node_structure_enum {
 
 /* These checks have to be special cased.  */
 #define NON_TYPE_CHECK(T) __extension__                                        \
-({  const tree __t = (T);                                              \
+({  __typeof (T) const __t = (T);                                      \
     if (TYPE_P (__t))                                                  \
       tree_not_class_check_failed (__t, tcc_type, __FILE__, __LINE__,  \
                                   __FUNCTION__);                       \
     __t; })
 
 #define TREE_VEC_ELT_CHECK(T, I) __extension__                         \
-(*({const tree __t = (T);                                              \
+(*({__typeof (T) const __t = (T);                                      \
     const int __i = (I);                                               \
     if (TREE_CODE (__t) != TREE_VEC)                                   \
       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,                \
@@ -768,9 +768,9 @@ enum tree_node_structure_enum {
                                 __FILE__, __LINE__, __FUNCTION__);     \
     &__t->vec.a[__i]; }))
 
-#define PHI_NODE_ELT_CHECK(t, i) __extension__                         \
-(*({const tree __t = t;                                                        \
-    const int __i = (i);                                               \
+#define PHI_NODE_ELT_CHECK(T, I) __extension__                         \
+(*({__typeof (T) const __t = (T);                                      \
+    const int __i = (I);                                               \
     if (TREE_CODE (__t) != PHI_NODE)                                   \
       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,        \
                         PHI_NODE, 0);                                  \
@@ -779,9 +779,9 @@ enum tree_node_structure_enum {
                                 __FILE__, __LINE__, __FUNCTION__);     \
     &__t->phi.a[__i]; }))
 
-#define OMP_CLAUSE_ELT_CHECK(t, i) __extension__                       \
-(*({const tree __t = t;                                                        \
-    const int __i = (i);                                               \
+#define OMP_CLAUSE_ELT_CHECK(T, I) __extension__                       \
+(*({__typeof (T) const __t = (T);                                              \
+    const int __i = (I);                                               \
     if (TREE_CODE (__t) != OMP_CLAUSE)                                 \
       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,        \
                         OMP_CLAUSE, 0);                                \
@@ -792,7 +792,7 @@ enum tree_node_structure_enum {
 
 /* Special checks for TREE_OPERANDs.  */
 #define TREE_OPERAND_CHECK(T, I) __extension__                         \
-(*({const tree __t = EXPR_CHECK (T);                                   \
+(*({__typeof (T) const __t = EXPR_CHECK (T);                           \
     const int __i = (I);                                               \
     if (GIMPLE_TUPLE_P (__t))                                          \
       gcc_unreachable ();                                              \
@@ -802,7 +802,7 @@ enum tree_node_structure_enum {
     &__t->exp.operands[__i]; }))
 
 #define TREE_OPERAND_CHECK_CODE(T, CODE, I) __extension__              \
-(*({const tree __t = (T);                                              \
+(*({__typeof (T) const __t = (T);                                      \
     const int __i = (I);                                               \
     if (TREE_CODE (__t) != CODE)                                       \
       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, (CODE), 0);\
@@ -813,7 +813,7 @@ enum tree_node_structure_enum {
 
 /* Special checks for GIMPLE_STMT_OPERANDs.  */
 #define GIMPLE_STMT_OPERAND_CHECK(T, I) __extension__                  \
-(*({const tree __t = GIMPLE_STMT_CHECK (T);                            \
+(*({__typeof (T) const __t = GIMPLE_STMT_CHECK (T);                    \
     const int __i = (I);                                               \
     if (__i < 0 || __i >= TREE_OPERAND_LENGTH (__t))                   \
       tree_operand_check_failed (__i, __t,                             \
@@ -822,7 +822,7 @@ enum tree_node_structure_enum {
 
 #define TREE_RTL_OPERAND_CHECK(T, CODE, I) __extension__               \
 (*(rtx *)                                                              \
- ({const tree __t = (T);                                               \
+ ({__typeof (T) const __t = (T);                                       \
     const int __i = (I);                                               \
     if (TREE_CODE (__t) != (CODE))                                     \
       tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, (CODE), 0); \
@@ -841,7 +841,7 @@ enum tree_node_structure_enum {
    are chained together.  */
 
 #define TREE_CHAIN(NODE) __extension__ \
-(*({const tree __t = (NODE);                                   \
+(*({__typeof (NODE) const __t = (NODE);                                \
     if (GIMPLE_TUPLE_P (__t))                                  \
       gcc_unreachable ();                                      \
     &__t->common.chain; }))
@@ -851,7 +851,7 @@ enum tree_node_structure_enum {
    In ARRAY_TYPE nodes, this is the type of the elements.
    In VECTOR_TYPE nodes, this is the type of the elements.  */
 #define TREE_TYPE(NODE) __extension__ \
-(*({const tree __t = (NODE);                                   \
+(*({__typeof (NODE) const __t = (NODE);                                        \
     if (GIMPLE_TUPLE_P (__t))                                  \
       gcc_unreachable ();                                      \
     &__t->common.type; }))