diff mbox

[C++] PR 56722

Message ID 515099ED.8060304@oracle.com
State New
Headers show

Commit Message

Paolo Carlini March 25, 2013, 6:39 p.m. UTC
Hi,

avoid a Seg fault on invalid by preliminarily checking 
DECL_LANG_SPECIFIC. The resulting error message is very similar to clang's.

Tested x86_64-linux. Ok mainline and branch?

Thanks,
Paolo.

////////////////////////
/cp
2013-03-25  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/56722
	* decl.c (cp_finish_decl): Check DECL_LANG_SPECIFIC before
	DECL_TEMPLATE_INSTANTIATION.

/testsuite
2013-03-25  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/56722
	* g++.dg/cpp0x/range-for23.C: New.

Comments

Jason Merrill March 25, 2013, 7:31 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 197053)
+++ cp/decl.c	(working copy)
@@ -6111,7 +6111,8 @@  cp_finish_decl (tree decl, tree init, bool init_co
       tree d_init;
       if (init == NULL_TREE)
 	{
-	  if (DECL_TEMPLATE_INSTANTIATION (decl)
+	  if (DECL_LANG_SPECIFIC (decl)
+	      && DECL_TEMPLATE_INSTANTIATION (decl)
 	      && !DECL_TEMPLATE_INSTANTIATED (decl))
 	    {
 	      /* init is null because we're deferring instantiating the
Index: testsuite/g++.dg/cpp0x/range-for23.C
===================================================================
--- testsuite/g++.dg/cpp0x/range-for23.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/range-for23.C	(working copy)
@@ -0,0 +1,8 @@ 
+// PR c++/56722
+// { dg-do compile { target c++11 } }
+
+int main()
+{
+  for (const auto& i, 21)  // { dg-error "has no initializer|expected" }
+    i;
+}