diff options
author | Zack Weinberg <zackw@stanford.edu> | 2001-08-04 00:20:37 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2001-08-04 00:20:37 +0000 |
commit | 1310497511d2ffb29fc4cf42d04606ea9081e76f (patch) | |
tree | 06e038fe1d38bc55a98f531dcdfb7cf9d2bf4cb5 /gcc/builtins.c | |
parent | 7335a34984e564b6fb30877390c11dc98cc53ef8 (diff) | |
download | gcc-1310497511d2ffb29fc4cf42d04606ea9081e76f.zip gcc-1310497511d2ffb29fc4cf42d04606ea9081e76f.tar.gz gcc-1310497511d2ffb29fc4cf42d04606ea9081e76f.tar.bz2 |
builtins.c (fold_builtin_constant_p): Return integer_zero_node for complex expressions when cfun == 0.
* builtins.c (fold_builtin_constant_p): Return integer_zero_node
for complex expressions when cfun == 0.
* doc/extend.texi: Document that __builtin_constant_p can be
used in data initializers as well as functions.
* gcc.dg/bconstp-1.c: New test.
From-SVN: r44619
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 62e0000..08d2bb7 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -3793,10 +3793,14 @@ fold_builtin_constant_p (arglist) has side effects, show we don't know it to be a constant. Likewise if it's a pointer or aggregate type since in those case we only want literals, since those are only optimized - when generating RTL, not later. */ + when generating RTL, not later. + And finally, if we are compiling an initializer, not code, we + need to return a definite result now; there's not going to be any + more optimization done. */ if (TREE_SIDE_EFFECTS (arglist) || cse_not_expected || AGGREGATE_TYPE_P (TREE_TYPE (arglist)) - || POINTER_TYPE_P (TREE_TYPE (arglist))) + || POINTER_TYPE_P (TREE_TYPE (arglist)) + || cfun == 0) return integer_zero_node; return 0; |