re PR c++/85015 (internal compiler error: tree check: expected class 'type', have...
authorJakub Jelinek <jakub@redhat.com>
Fri, 23 Mar 2018 20:54:50 +0000 (21:54 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 23 Mar 2018 20:54:50 +0000 (21:54 +0100)
PR c++/85015
* decl.c (compute_array_index_type): Set osize to mark_rvalue_use
result.

* g++.dg/cpp0x/pr85015.C: New test.

From-SVN: r258822

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

index 619161bf323583a70c9cfb4d8f7ac8a5733120b3..52af546409097d9cd2e1f1a8b190e1239f6c0d9f 100644 (file)
@@ -1,5 +1,9 @@
 2018-03-23  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/85015
+       * decl.c (compute_array_index_type): Set osize to mark_rvalue_use
+       result.
+
        PR c++/84942
        * pt.c (tsubst_copy_and_build) <case FIX_TRUNC_EXPR>: Replace
        cp_build_unary_op call with gcc_unreachable ().
index 0aa4ac20b53bbb76b181715e1e90b07a10204531..96d4b723b4a19b87463e56bd9f00529724d51f77 100644 (file)
@@ -9520,7 +9520,7 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain)
 
   if (!type_dependent_expression_p (size))
     {
-      size = mark_rvalue_use (size);
+      osize = size = mark_rvalue_use (size);
 
       if (cxx_dialect < cxx11 && TREE_CODE (size) == NOP_EXPR
          && TREE_SIDE_EFFECTS (size))
index 419bd560dc5a0968bbd617adbc6a6eaa50e1f124..99696f3745c97a918ccadc676a88f0df929fba1b 100644 (file)
@@ -1,5 +1,8 @@
 2018-03-23  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/85015
+       * g++.dg/cpp0x/pr85015.C: New test.
+
        PR c++/84942
        * g++.dg/cpp1y/pr84942.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr85015.C b/gcc/testsuite/g++.dg/cpp0x/pr85015.C
new file mode 100644 (file)
index 0000000..38dc7cb
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/85015
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+void
+foo ()
+{
+  int &&c = v + 1;             // { dg-error "was not declared in this scope" }
+  struct S {                   // { dg-message "declared here" "" { target *-*-* } .-1 }
+    void bar () { int a[c]; }  // { dg-error "use of local variable with automatic storage from containing function" }
+  } e;
+}