summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2001-05-25 06:34:16 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2001-05-25 06:34:16 +0000
commiteb8543b35307e95a8f74645cea36a9153869fdda (patch)
tree4639b32f032e98248f5d2e4e613de14e99564633 /gcc
parenta16ad7794695d54a794e023556cebd61e20bd4c2 (diff)
downloadgcc-eb8543b35307e95a8f74645cea36a9153869fdda.tar.gz
c-typeck.c (digest_init): Issue error messages about invalid constants, not warnings.
* c-typeck.c (digest_init): Issue error messages about invalid constants, not warnings. From-SVN: r42560
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-typeck.c15
-rw-r--r--gcc/testsuite/gcc.dg/noncompile/20010524-1.c2
3 files changed, 18 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f464a4a05f4..c2c6e2992e5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2001-05-24 Mark Mitchell <mark@codesourcery.com>
+ * c-typeck.c (digest_init): Issue error messages about
+ invalid constants, not warnings.
+
+2001-05-24 Mark Mitchell <mark@codesourcery.com>
+
* invoke.texi (-fno-builtin): Document that this is always on
in C++.
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 3cbf6c6f3ef..71dae28e909 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -4791,14 +4791,21 @@ digest_init (type, init, require_constant, constructor_constant)
if (flag_pedantic_errors)
inside_init = error_mark_node;
}
- else if (require_constant && ! TREE_CONSTANT (inside_init))
+ else if (require_constant
+ && (!TREE_CONSTANT (inside_init)
+ /* This test catches things like `7 / 0' which
+ result in an expression for which TREE_CONSTANT
+ is true, but which is not actually something
+ that is a legal constant. We really should not
+ be using this function, because it is a part of
+ the back-end. Instead, the expression should
+ already have been turned into ERROR_MARK_NODE. */
+ || !initializer_constant_valid_p (inside_init,
+ TREE_TYPE (inside_init))))
{
error_init ("initializer element is not constant");
inside_init = error_mark_node;
}
- else if (require_constant
- && initializer_constant_valid_p (inside_init, TREE_TYPE (inside_init)) == 0)
- pedwarn ("initializer element is not computable at load time");
return inside_init;
}
diff --git a/gcc/testsuite/gcc.dg/noncompile/20010524-1.c b/gcc/testsuite/gcc.dg/noncompile/20010524-1.c
new file mode 100644
index 00000000000..754a38c147f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/noncompile/20010524-1.c
@@ -0,0 +1,2 @@
+int i = 7 / 0; /* { dg-error "not constant" } */
+