tree.h: Declare folding_initializer.
authorMark Shinwell <shinwell@codesourcery.com>
Sun, 4 Jun 2006 16:28:55 +0000 (16:28 +0000)
committerMark Shinwell <shinwell@gcc.gnu.org>
Sun, 4 Jun 2006 16:28:55 +0000 (16:28 +0000)
gcc:

* tree.h: Declare folding_initializer.
* builtins.c (fold_builtin_constant_p): Give definite answer
if folding inside an initializer.
* fold-const.c: Define folding_initializer.
(START_FOLD_INIT): Save and then set folding_initializer.
(END_FOLD_INIT): Restore folding_initializer.

gcc/testsuite:

        * gcc.c-torture/compile/builtin_constant_p.c: New test.

From-SVN: r114358

gcc/ChangeLog
gcc/builtins.c
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/tree.h

index fd3d122..d7dcfd1 100644 (file)
@@ -1,3 +1,12 @@
+2006-06-04  Mark Shinwell  <shinwell@codesourcery.com>
+
+       * tree.h: Declare folding_initializer.
+       * builtins.c (fold_builtin_constant_p): Give definite answer
+       if folding inside an initializer.
+       * fold-const.c: Define folding_initializer.
+       (START_FOLD_INIT): Save and then set folding_initializer.
+       (END_FOLD_INIT): Restore folding_initializer.
+
 2006-06-04  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/27039
index 7113681..603106a 100644 (file)
@@ -6495,7 +6495,8 @@ fold_builtin_constant_p (tree arglist)
   if (TREE_SIDE_EFFECTS (arglist)
       || AGGREGATE_TYPE_P (TREE_TYPE (arglist))
       || POINTER_TYPE_P (TREE_TYPE (arglist))
-      || cfun == 0)
+      || cfun == 0
+      || folding_initializer)
     return integer_zero_node;
 
   return 0;
index 3c8575e..6f19704 100644 (file)
@@ -59,6 +59,10 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 #include "langhooks.h"
 #include "md5.h"
 
+/* Non-zero if we are folding constants inside an initializer; zero
+   otherwise.  */
+int folding_initializer = 0;
+
 /* The following constants represent a bit based encoding of GCC's
    comparison operators.  This encoding simplifies transformations
    on relational comparison operators, such as AND and OR.  */
@@ -11708,16 +11712,19 @@ fold_build3_stat (enum tree_code code, tree type, tree op0, tree op1, tree op2
   int saved_trapping_math = flag_trapping_math;\
   int saved_rounding_math = flag_rounding_math;\
   int saved_trapv = flag_trapv;\
+  int saved_folding_initializer = folding_initializer;\
   flag_signaling_nans = 0;\
   flag_trapping_math = 0;\
   flag_rounding_math = 0;\
-  flag_trapv = 0
+  flag_trapv = 0;\
+  folding_initializer = 1;
 
 #define END_FOLD_INIT \
   flag_signaling_nans = saved_signaling_nans;\
   flag_trapping_math = saved_trapping_math;\
   flag_rounding_math = saved_rounding_math;\
-  flag_trapv = saved_trapv
+  flag_trapv = saved_trapv;\
+  folding_initializer = saved_folding_initializer;
 
 tree
 fold_build1_initializer (enum tree_code code, tree type, tree op)
index 21fa273..a1f5273 100644 (file)
@@ -1,3 +1,7 @@
+2006-06-04  Mark Shinwell  <shinwell@codesourcery.com>
+
+       * gcc.c-torture/compile/builtin_constant_p.c: New test.
+
 2006-06-04  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/27039
index 55a5d8f..b377e38 100644 (file)
@@ -4142,6 +4142,10 @@ extern void using_eh_for_cleanups (void);
 
 /* In fold-const.c */
 
+/* Non-zero if we are folding constants inside an initializer; zero
+   otherwise.  */
+extern int folding_initializer;
+
 /* Fold constants as much as possible in an expression.
    Returns the simplified expression.
    Acts only on the top level of the expression;