Patchwork [C++] PR 49776

login
register
mail settings
Submitter Paolo Carlini
Date July 26, 2011, 9:54 a.m.
Message ID <4E2E8EC3.2060109@oracle.com>
Download mbox | patch
Permalink /patch/106820/
State New
Headers show

Comments

Paolo Carlini - July 26, 2011, 9:54 a.m.
Hi,

another simple fix for an ICE on invalid. Tested x86_64-linux.

Ok?

Thanks,
Paolo.

////////////////////////
/cp
2011-07-26  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/49776
	* typeck.c (cp_build_modify_expr): Check digest_init return value
	for error_mark_node.

/testsuite
2011-07-26  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/49776
	* g++.dg/cpp0x/constexpr-49776.C: New.
Jason Merrill - July 26, 2011, 5:01 p.m.
OK.

Jason

Patch

Index: testsuite/g++.dg/cpp0x/constexpr-49776.C
===================================================================
--- testsuite/g++.dg/cpp0x/constexpr-49776.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/constexpr-49776.C	(revision 0)
@@ -0,0 +1,17 @@ 
+// PR c++/49776
+// { dg-options -std=c++0x }
+
+struct s
+{
+  int i[1];
+
+  template<class... Types>
+    constexpr s(Types... args)
+    : i{args...}  // { dg-error "cannot convert" }
+    { }
+};
+
+int main()
+{
+  s test = nullptr;
+}
Index: cp/typeck.c
===================================================================
--- cp/typeck.c	(revision 176786)
+++ cp/typeck.c	(working copy)
@@ -6753,6 +6753,8 @@  cp_build_modify_expr (tree lhs, enum tree_code mod
 	  if (check_array_initializer (lhs, lhstype, newrhs))
 	    return error_mark_node;
 	  newrhs = digest_init (lhstype, newrhs, complain);
+	  if (newrhs == error_mark_node)
+	    return error_mark_node;
 	}
 
       else if (!same_or_base_type_p (TYPE_MAIN_VARIANT (lhstype),