diff mbox

C PATCH for c/71418 (ICE with bogus array dimension and _Alignas)

Message ID 20160607151645.GB3014@redhat.com
State New
Headers show

Commit Message

Marek Polacek June 7, 2016, 3:16 p.m. UTC
Another error-recovery bug.  This time TYPE was error_mark_node but
min_align_of_type accessed it via TYPE_ALIGN.  So we better check that we're
operating on a type.

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

2016-06-07  Marek Polacek  <polacek@redhat.com>

	PR c/71418
	* c-decl.c (grokdeclarator): Check TYPE_P.

	* gcc.dg/noncompile/pr71418.c: New test.


	Marek

Comments

Joseph Myers June 7, 2016, 9:38 p.m. UTC | #1
On Tue, 7 Jun 2016, Marek Polacek wrote:

> Another error-recovery bug.  This time TYPE was error_mark_node but
> min_align_of_type accessed it via TYPE_ALIGN.  So we better check that we're
> operating on a type.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

OK.
diff mbox

Patch

diff --git gcc/c/c-decl.c gcc/c/c-decl.c
index d79802e..ac83e2f 100644
--- gcc/c/c-decl.c
+++ gcc/c/c-decl.c
@@ -6313,7 +6313,7 @@  grokdeclarator (const struct c_declarator *declarator,
 	}
       else if (TREE_CODE (type) == FUNCTION_TYPE)
 	error_at (loc, "alignment specified for function %qE", name);
-      else if (declspecs->align_log != -1)
+      else if (declspecs->align_log != -1 && TYPE_P (type))
 	{
 	  alignas_align = 1U << declspecs->align_log;
 	  if (alignas_align < min_align_of_type (type))
diff --git gcc/testsuite/gcc.dg/noncompile/pr71418.c gcc/testsuite/gcc.dg/noncompile/pr71418.c
index e69de29..e3243f3 100644
--- gcc/testsuite/gcc.dg/noncompile/pr71418.c
+++ gcc/testsuite/gcc.dg/noncompile/pr71418.c
@@ -0,0 +1,4 @@ 
+/* PR c/71418 */
+/* { dg-do compile } */
+
+_Alignas (int) int a[7++]; /* { dg-error "lvalue required" } */