re PR c++/47969 ([C++0x] ICE: SIGSEGV in compute_array_index_type (cp/decl.c:7522))
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 2 May 2011 12:44:15 +0000 (12:44 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 2 May 2011 12:44:15 +0000 (12:44 +0000)
/cp
2011-05-02  Paolo Carlini  <paolo.carlini@oracle.com>

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  <paolo.carlini@oracle.com>

PR c++/47969
* g++.dg/cpp0x/constexpr-47969.C: New.

From-SVN: r173249

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-47969.C [new file with mode: 0644]

index a62cce9720ea4e501be7f3e49866a57f6720a65a..d53c4b3edc18fca358593523a86170d5efe3e26e 100644 (file)
@@ -1,3 +1,9 @@
+2011-05-02  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/47969
+       * decl.c (compute_array_index_type): Check build_expr_type_conversion
+       return value for NULL_TREE.
+
 2011-04-29  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/48606
index 5bf637e507d3651729b3b1d09156fc43ac97263c..0a2e1dd5cc5f5482d59b6100aa1dc15493aa05d1 100644 (file)
@@ -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);
index 02807dcc4e0711c2669cba4b8ab4c3eede5c171b..769d8658bbff5b217aa5d2768b2f6a3d0031f466 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-02  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/47969
+       * g++.dg/cpp0x/constexpr-47969.C: New.
+
 2011-05-02  Ira Rosen  <ira.rosen@linaro.org>
 
        PR testsuite/48498
@@ -7,7 +12,7 @@
        vect_no_align targets.
 
 2011-05-01  Xinliang David Li  <davidxl@google.com>
-       
+
        * 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 (file)
index 0000000..c950a36
--- /dev/null
@@ -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" }