diff mbox

C++ PATCH for c++/78647 (ICE-on-invalid with attribute_fallthrough_p)

Message ID 20161205203730.GE2337@redhat.com
State New
Headers show

Commit Message

Marek Polacek Dec. 5, 2016, 8:37 p.m. UTC
We were crashing on this invalid test because cp_parser_std_attribute_spec_seq
in cp_parser_statement returned error_mark_node, but the subsequent
attribute_fallthrough_p wasn't prepared for that.

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

2016-12-05  Marek Polacek  <polacek@redhat.com>

	PR c++/78647
	* c-family/c-common.c (attribute_fallthrough_p): Return false for
	error_mark_node.

	* g++.dg/parse/error58.C: New.


	Marek

Comments

Marek Polacek Dec. 12, 2016, 5:44 p.m. UTC | #1
Ping.

On Mon, Dec 05, 2016 at 09:37:30PM +0100, Marek Polacek wrote:
> We were crashing on this invalid test because cp_parser_std_attribute_spec_seq
> in cp_parser_statement returned error_mark_node, but the subsequent
> attribute_fallthrough_p wasn't prepared for that.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
> 
> 2016-12-05  Marek Polacek  <polacek@redhat.com>
> 
> 	PR c++/78647
> 	* c-family/c-common.c (attribute_fallthrough_p): Return false for
> 	error_mark_node.
> 
> 	* g++.dg/parse/error58.C: New.
> 
> diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
> index 0749361..c8e1f0d 100644
> --- gcc/c-family/c-common.c
> +++ gcc/c-family/c-common.c
> @@ -5558,6 +5558,8 @@ parse_optimize_options (tree args, bool attr_p)
>  bool
>  attribute_fallthrough_p (tree attr)
>  {
> +  if (attr == error_mark_node)
> +   return false;
>    tree t = lookup_attribute ("fallthrough", attr);
>    if (t == NULL_TREE)
>      return false;
> diff --git gcc/testsuite/g++.dg/parse/error58.C gcc/testsuite/g++.dg/parse/error58.C
> index e69de29..5ed6e1e 100644
> --- gcc/testsuite/g++.dg/parse/error58.C
> +++ gcc/testsuite/g++.dg/parse/error58.C
> @@ -0,0 +1,7 @@
> +// PR c++/78647
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-w" }
> +
> +struct A;
> +void foo ();
> +void f() { alignas (foo (A)); } // { dg-error "expected" "" }
> 
> 	Marek

	Marek
Jakub Jelinek Dec. 12, 2016, 5:45 p.m. UTC | #2
On Mon, Dec 12, 2016 at 06:44:19PM +0100, Marek Polacek wrote:
> Ping.
> 
> On Mon, Dec 05, 2016 at 09:37:30PM +0100, Marek Polacek wrote:
> > We were crashing on this invalid test because cp_parser_std_attribute_spec_seq
> > in cp_parser_statement returned error_mark_node, but the subsequent
> > attribute_fallthrough_p wasn't prepared for that.
> > 
> > Bootstrapped/regtested on x86_64-linux, ok for trunk?
> > 
> > 2016-12-05  Marek Polacek  <polacek@redhat.com>
> > 
> > 	PR c++/78647
> > 	* c-family/c-common.c (attribute_fallthrough_p): Return false for

No c-family/ prefix in c-family/ChangeLog.

> > 	error_mark_node.
> > 
> > 	* g++.dg/parse/error58.C: New.

Otherwise LGTM.

	Jakub
diff mbox

Patch

diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index 0749361..c8e1f0d 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -5558,6 +5558,8 @@  parse_optimize_options (tree args, bool attr_p)
 bool
 attribute_fallthrough_p (tree attr)
 {
+  if (attr == error_mark_node)
+   return false;
   tree t = lookup_attribute ("fallthrough", attr);
   if (t == NULL_TREE)
     return false;
diff --git gcc/testsuite/g++.dg/parse/error58.C gcc/testsuite/g++.dg/parse/error58.C
index e69de29..5ed6e1e 100644
--- gcc/testsuite/g++.dg/parse/error58.C
+++ gcc/testsuite/g++.dg/parse/error58.C
@@ -0,0 +1,7 @@ 
+// PR c++/78647
+// { dg-do compile { target c++11 } }
+// { dg-options "-w" }
+
+struct A;
+void foo ();
+void f() { alignas (foo (A)); } // { dg-error "expected" "" }