diff options
author | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-08-04 00:20:37 +0000 |
---|---|---|
committer | zack <zack@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-08-04 00:20:37 +0000 |
commit | f97c71a1d54442d59f290950d87736fb4674b030 (patch) | |
tree | 06e038fe1d38bc55a98f531dcdfb7cf9d2bf4cb5 /gcc/testsuite/gcc.dg/bconstp-1.c | |
parent | 1da98f7642b512007d26693e80218ce9a8f38e40 (diff) | |
download | gcc-f97c71a1d54442d59f290950d87736fb4674b030.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44619 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/bconstp-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/bconstp-1.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/bconstp-1.c b/gcc/testsuite/gcc.dg/bconstp-1.c new file mode 100644 index 00000000000..36831a5d6d5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/bconstp-1.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ + +/* This test checks that builtin_constant_p can be used safely in + initializers for static data. The macro X() defined below should + be an acceptable initializer expression no matter how complex its + argument is. */ + +extern int a; +extern int b; + +extern int foo(void); +extern int bar(void); + +#define X(exp) (__builtin_constant_p(exp) ? (exp) : -1) + +const short tests[] = { + X(0), + X(a), + X(0 && a), + X(a && b), + X(foo()), + X(0 && foo()), + X(a && foo()), + X(foo() && bar()) +}; |