aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-08-06 00:34:21 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-08-06 00:34:21 -0400
commit5c67ef9aef20c1be9e6214b2cf8ea86df1af5415 (patch)
tree97bd80367a5e914bb18bd4b665b11472a102349b /gcc/cp
parentde9ef71ca76369222554fcc2b4cb533c3b094289 (diff)
downloadgcc-5c67ef9aef20c1be9e6214b2cf8ea86df1af5415.zip
gcc-5c67ef9aef20c1be9e6214b2cf8ea86df1af5415.tar.gz
gcc-5c67ef9aef20c1be9e6214b2cf8ea86df1af5415.tar.bz2
re PR c++/49988 (constexpr on ctor invokes improper initialization)
PR c++/49988 * semantics.c (cxx_eval_array_reference): Handle failure to reduce the array operand to something we can work with. From-SVN: r177496
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/semantics.c9
2 files changed, 14 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9fe6450..3c1ad7f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2011-08-05 Jason Merrill <jason@redhat.com>
+
+ PR c++/49988
+ * semantics.c (cxx_eval_array_reference): Handle failure to
+ reduce the array operand to something we can work with.
+
2011-08-05 Gabriel Charette <gchare@google.com>
* decl.c (finish_function): Remove unecessary line 0 hack.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index ac24b77..2f02e69 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -6428,12 +6428,19 @@ cxx_eval_array_reference (const constexpr_call *call, tree t,
elem_type = TREE_TYPE (TREE_TYPE (ary));
if (TREE_CODE (ary) == CONSTRUCTOR)
len = CONSTRUCTOR_NELTS (ary);
- else
+ else if (TREE_CODE (ary) == STRING_CST)
{
elem_nchars = (TYPE_PRECISION (elem_type)
/ TYPE_PRECISION (char_type_node));
len = (unsigned) TREE_STRING_LENGTH (ary) / elem_nchars;
}
+ else
+ {
+ /* We can't do anything with other tree codes, so use
+ VERIFY_CONSTANT to complain and fail. */
+ VERIFY_CONSTANT (ary);
+ gcc_unreachable ();
+ }
if (compare_tree_int (index, len) >= 0)
{
if (tree_int_cst_lt (index, array_type_nelts_top (TREE_TYPE (ary))))