Patchwork [C++] Fix ICE in merge_exception_specifiers (PR c++/55652)

login
register
mail settings
Submitter Jakub Jelinek
Date Dec. 12, 2012, 7:42 p.m.
Message ID <20121212194239.GD2315@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/205634/
State New
Headers show

Comments

Jakub Jelinek - Dec. 12, 2012, 7:42 p.m.
Hi!

This is a follow-up fix for my earlier commit, in merge_exception_specifiers
can be NULL, noex == boolean_true_node comparison then was false, but
operand_equal_p crashes on it.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2012-12-12  Jakub Jelinek  <jakub@redhat.com>

	PR c++/55652
	* typeck2.c (merge_exception_specifiers): Don't call operand_equal_p
	if noex is NULL.

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


	Jakub
Jason Merrill - Dec. 13, 2012, 2:30 p.m.
OK.

Jason

Patch

--- gcc/cp/typeck2.c.jj	2012-12-06 19:54:56.000000000 +0100
+++ gcc/cp/typeck2.c	2012-12-12 10:12:33.468377515 +0100
@@ -1871,7 +1871,7 @@  merge_exception_specifiers (tree list, t
       /* If ADD is a deferred noexcept, we must have been called from
 	 process_subob_fn.  For implicitly declared functions, we build up
 	 a list of functions to consider at instantiation time.  */
-      if (operand_equal_p (noex, boolean_true_node, 0))
+      if (noex && operand_equal_p (noex, boolean_true_node, 0))
 	noex = NULL_TREE;
       gcc_assert (fn && (!noex || is_overloaded_fn (noex)));
       noex = build_overload (fn, noex);
--- gcc/testsuite/g++.dg/cpp0x/noexcept19.C.jj	2012-12-12 10:11:20.182816929 +0100
+++ gcc/testsuite/g++.dg/cpp0x/noexcept19.C	2012-12-12 10:10:50.000000000 +0100
@@ -0,0 +1,29 @@ 
+// PR c++/55652
+// { dg-do compile }
+// { dg-options "-std=c++11" }
+
+template <typename T>
+struct A
+{
+  static const bool a = false;
+};
+
+template <typename X, typename Y = A <X>>
+struct B
+{
+  B () noexcept (A <Y>::a) {}
+};
+
+template <typename X, typename Y>
+struct C
+{
+  X x;
+  Y y;
+};
+
+struct D
+{
+  D () throw (int);
+};
+
+C <D, B <D>> c;