public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/61670 (ice-after-error with null DECL_SIZE)
@ 2015-03-25 13:46 Marek Polacek
  2015-03-25 19:26 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2015-03-25 13:46 UTC (permalink / raw)
  To: GCC Patches, Jason Merrill

The following fixes an ICE on invalid code by checking that DECL_SIZE is
not null before feeding it to integer_zerop.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2015-03-25  Marek Polacek  <polacek@redhat.com>

	PR c++/61670
	* class.c (remove_zero_width_bit_fields): Check for null DECL_SIZE.

	* g++.dg/template/pr61670.C: New test.

diff --git gcc/cp/class.c gcc/cp/class.c
index 0518320..c2d4201 100644
--- gcc/cp/class.c
+++ gcc/cp/class.c
@@ -5434,7 +5434,8 @@ remove_zero_width_bit_fields (tree t)
 	     DECL_INITIAL (*fieldsp).
 	     check_bitfield_decl eventually sets DECL_SIZE (*fieldsp)
 	     to that width.  */
-	  && integer_zerop (DECL_SIZE (*fieldsp)))
+	  && (DECL_SIZE (*fieldsp) == NULL_TREE
+	      || integer_zerop (DECL_SIZE (*fieldsp))))
 	*fieldsp = DECL_CHAIN (*fieldsp);
       else
 	fieldsp = &DECL_CHAIN (*fieldsp);
diff --git gcc/testsuite/g++.dg/template/pr61670.C gcc/testsuite/g++.dg/template/pr61670.C
index e69de29..d244efa 100644
--- gcc/testsuite/g++.dg/template/pr61670.C
+++ gcc/testsuite/g++.dg/template/pr61670.C
@@ -0,0 +1,9 @@
+// PR c++/61670
+// { dg-do compile }
+
+template <class>
+class A {
+  A: 0 // { dg-error "" }
+};
+
+A<int> a;

	Marek

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: C++ PATCH for c++/61670 (ice-after-error with null DECL_SIZE)
  2015-03-25 13:46 C++ PATCH for c++/61670 (ice-after-error with null DECL_SIZE) Marek Polacek
@ 2015-03-25 19:26 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2015-03-25 19:26 UTC (permalink / raw)
  To: Marek Polacek, GCC Patches

OK.

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-25 19:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-25 13:46 C++ PATCH for c++/61670 (ice-after-error with null DECL_SIZE) Marek Polacek
2015-03-25 19:26 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).