re PR c++/60250 ([c++1y] ICE using lambda for array size)
authorJason Merrill <jason@redhat.com>
Fri, 21 Feb 2014 14:01:29 +0000 (09:01 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 21 Feb 2014 14:01:29 +0000 (09:01 -0500)
PR c++/60250
* parser.c (cp_parser_direct_declarator): Don't wrap a
type-dependent expression in a NOP_EXPR.

From-SVN: r207996

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/cpp1y/vla12.C [new file with mode: 0644]

index e175768..9f04144 100644 (file)
@@ -1,5 +1,9 @@
 2014-02-21  Jason Merrill  <jason@redhat.com>
 
+       PR c++/60250
+       * parser.c (cp_parser_direct_declarator): Don't wrap a
+       type-dependent expression in a NOP_EXPR.
+
        PR c++/60251
        * lambda.c (is_normal_capture_proxy): Handle VLA capture.
 
index e067a02..6f19ae2 100644 (file)
@@ -17233,7 +17233,8 @@ cp_parser_direct_declarator (cp_parser* parser,
                                   "array bound is not an integer constant");
                  bounds = error_mark_node;
                }
-             else if (processing_template_decl)
+             else if (processing_template_decl
+                      && !type_dependent_expression_p (bounds))
                {
                  /* Remember this wasn't a constant-expression.  */
                  bounds = build_nop (TREE_TYPE (bounds), bounds);
diff --git a/gcc/testsuite/g++.dg/cpp1y/vla12.C b/gcc/testsuite/g++.dg/cpp1y/vla12.C
new file mode 100644 (file)
index 0000000..df47f26
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/60250
+// { dg-options "-std=c++1y -pedantic-errors" }
+
+template<typename> void foo()
+{
+  typedef int T[ ([](){ return 1; }()) ]; // { dg-error "runtime bound" }
+}