aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/builtins.c3
-rw-r--r--gcc/fold-const.c11
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/tree.h4
5 files changed, 28 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fd3d122..d7dcfd1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 7113681..603106a 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -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;
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 3c8575e..6f19704 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -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)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 21fa273..a1f5273 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
diff --git a/gcc/tree.h b/gcc/tree.h
index 55a5d8f..b377e38 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -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;