This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: cleanup for conversion exprs code patterns (7/16)


 Hi,

 this series of patches is doing small cleanup in using conversion
 expressions code patterns. There is a lot of duplicate code patterns
 for conversion expressions (CONVERT_EXPR, NOP_EXPR, NON_LVALUE_EXPR)
 that can be substituted by macro. Patterns are:
 
 (TREE_CODE (EXP) == NOP_EXPR || TREE_CODE (EXP) == CONVERT_EXPR) 
 -> TEST_CONVERT_NOPS_P(EXP)

 (TREE_CODE (EXP) == NOP_EXPR || TREE_CODE (EXP) == CONVERT_EXPR
  || TREE_CODE (EXP) == NON_LVALUE_EXPR)
 -> TEST_NOPS_P(EXP)

 case NOP_EXPR: case CONVERT_EXPR
 -> CASE_CONVERT_NOPS

 case NOP_EXPR: case CONVERT_EXPR: case NON_LVALUE_EXPR
 -> CASE_NOPS

 while (TREE_CODE (EXP) == NOP_EXPR 
        || TREE_CODE (EXP) == CONVERT_EXPR
        || TREE_CODE (EXP) == NON_LVALUE_EXPR)
    (EXP) = TREE_OPERAND (EXP, 0)
 -> STRIP_NOPS_UNSAFE(EXP)

 -> means replaced by

 Patch 1: Add new macros (TEST_CONVERT_NOPS_P(EXP), TEST_NOPS_P(EXP),
          CASE_CONVERT_NOPS, CASE_NOPS, STRIP_NOPS_UNSAFE(EXP)).
 Patch 2-4: Add support of TEST_CONVERT_NOPS_P.
 Patch 5-8: Add support of TEST_NOPS_P.
 Patch 9-11: Add support of CASE_CONVERT_NOPS.
 Patch 12-13: Add support of CASE_NOPS.
 Patch 14-16: Add support of STRIP_NOPS_UNSAFE.

 Bootstraped and tested on x86_64 x86_64 GNU/Linux.

 Ok?

 Greetings 
 Tomas


 Patch 7

 Changelog:

2008-03-13  Tomas Bily  <tbily@suse.cz>

	* typeck.c (maybe_warn_about_returning_address_of_local): Use TEST_NOPS_P.



Index: gcc/cp/typeck.c
===================================================================
--- gcc/cp/typeck.c	(revision 132974)
+++ gcc/cp/typeck.c	(working copy)
@@ -6543,9 +6540,7 @@ maybe_warn_about_returning_address_of_lo
     {
       if (TREE_CODE (whats_returned) == COMPOUND_EXPR)
 	whats_returned = TREE_OPERAND (whats_returned, 1);
-      else if (TREE_CODE (whats_returned) == CONVERT_EXPR
-	       || TREE_CODE (whats_returned) == NON_LVALUE_EXPR
-	       || TREE_CODE (whats_returned) == NOP_EXPR)
+      else if (TEST_NOPS_P (whats_returned))
 	whats_returned = TREE_OPERAND (whats_returned, 0);
       else
 	break;
Index: gcc/cp/typeck2.c
===================================================================
--- gcc/cp/typeck2.c	(revision 132974)
+++ gcc/cp/typeck2.c	(working copy)
@@ -712,8 +712,7 @@ digest_init (tree type, tree init)
 
       /* Skip any conversions since we'll be outputting the underlying
 	 constant.  */
-      while (TREE_CODE (*exp) == NOP_EXPR || TREE_CODE (*exp) == CONVERT_EXPR
-	     || TREE_CODE (*exp) == NON_LVALUE_EXPR)
+      while (TEST_NOPS_P (*exp))
 	exp = &TREE_OPERAND (*exp, 0);
 
       *exp = cplus_expand_constant (*exp);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]