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/doc | |
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/doc')
-rw-r--r-- | gcc/doc/extend.texi | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 787b722..b7c2496 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -3889,6 +3889,26 @@ never return 1 when you call the inline function with a string constant or compound literal (@pxref{Compound Literals}) and will not return 1 when you pass a constant numeric value to the inline function unless you specify the @option{-O} option. + +You may also use @code{__builtin_constant_p} in initializers for static +data. For instance, you can write + +@smallexample +static const int table[] = { + __builtin_constant_p (EXPRESSION) ? (EXPRESSION) : -1, + /* ... */ +}; +@end smallexample + +@noindent +This is an acceptable initializer even if @var{EXPRESSION} is not a +constant expression. GCC must be more conservative about evaluating the +built-in in this case, because it has no opportunity to perform +optimization. + +Previous versions of GCC did not accept this built-in in data +initializers. The earliest version where it is completely safe is +3.0.1. @end deftypefn @deftypefn {Built-in Function} long __builtin_expect (long @var{exp}, long @var{c}) |