This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/60250 (ICE with invalid array bound)


A type-dependent expression can have NULL TREE_TYPE, and if we wrap it in a NOP_EXPR also with NULL type, that confuses things. Let's not try to do that.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 5564347b2b7b39d92f8f3b8307bc8ed8551e4d91
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Feb 20 23:46:00 2014 -0500

    	PR c++/60250
    	* parser.c (cp_parser_direct_declarator): Don't wrap a
    	type-dependent expression in a NOP_EXPR.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index d8ccd2b..d6c176f 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -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
index 0000000..df47f26
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/vla12.C
@@ -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" }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]