summaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2001-08-04 00:20:37 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2001-08-04 00:20:37 +0000
commitf97c71a1d54442d59f290950d87736fb4674b030 (patch)
tree06e038fe1d38bc55a98f531dcdfb7cf9d2bf4cb5 /gcc/testsuite
parent1da98f7642b512007d26693e80218ce9a8f38e40 (diff)
downloadgcc-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')
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/bconstp-1.c25
2 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2424e7451f3..d0813ca70be 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2001-08-03 Zack Weinberg <zackw@stanford.edu>
+
+ * gcc.dg/bconstp-1.c: New test.
+
2001-08-03 Richard Henderson <rth@redhat.com>
* g++.dg/eh/filter1.C, g++.dg/eh/filter2.C: New tests.
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())
+};