From 9fd15228e24f6f1420437deeac052dd7342444a4 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 2 May 2011 12:44:15 +0000 Subject: [PATCH] re PR c++/47969 ([C++0x] ICE: SIGSEGV in compute_array_index_type (cp/decl.c:7522)) /cp 2011-05-02 Paolo Carlini PR c++/47969 * decl.c (compute_array_index_type): Check build_expr_type_conversion return value for NULL_TREE. /testsuite 2011-05-02 Paolo Carlini PR c++/47969 * g++.dg/cpp0x/constexpr-47969.C: New. From-SVN: r173249 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 11 +++++++++++ gcc/testsuite/ChangeLog | 7 ++++++- gcc/testsuite/g++.dg/cpp0x/constexpr-47969.C | 11 +++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-47969.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a62cce9720e..d53c4b3edc1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-05-02 Paolo Carlini + + PR c++/47969 + * decl.c (compute_array_index_type): Check build_expr_type_conversion + return value for NULL_TREE. + 2011-04-29 Paolo Carlini PR c++/48606 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5bf637e507d..0a2e1dd5cc5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7609,6 +7609,17 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) && CLASSTYPE_LITERAL_P (type)) { size = build_expr_type_conversion (WANT_INT, size, true); + if (!size) + { + if (!(complain & tf_error)) + return error_mark_node; + if (name) + error ("size of array %qD has non-integral type %qT", + name, type); + else + error ("size of array has non-integral type %qT", type); + size = integer_one_node; + } if (size == error_mark_node) return error_mark_node; type = TREE_TYPE (size); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 02807dcc4e0..769d8658bbf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-05-02 Paolo Carlini + + PR c++/47969 + * g++.dg/cpp0x/constexpr-47969.C: New. + 2011-05-02 Ira Rosen PR testsuite/48498 @@ -7,7 +12,7 @@ vect_no_align targets. 2011-05-01 Xinliang David Li - + * gcc.dg/tree-ssa/integer-addr.c: New test. * gcc.dg/tree-ssa/alias_bug.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-47969.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-47969.C new file mode 100644 index 00000000000..c950a3642fe --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-47969.C @@ -0,0 +1,11 @@ +// PR c++/47969 +// { dg-options -std=c++0x } + +struct A +{ + // constexpr operator int () { return 1; } +}; + +constexpr A a = A(); + +int ar[a]; // { dg-error "has non-integral type" } -- 2.30.2