diff mbox series

[C++] Fix namespace attribute error recovery (PR c++/85140)

Message ID 20180403160655.GZ8577@tucnak
State New
Headers show
Series [C++] Fix namespace attribute error recovery (PR c++/85140) | expand

Commit Message

Jakub Jelinek April 3, 2018, 4:06 p.m. UTC
Hi!

If at least one attribute is errorneous, we get error_mark_node instead
of the attributes list.

The following patch fixes error recovery for that.  Bootstrapped/regtested
on x86_64-linux and i686-linux, ok for trunk?

2018-04-03  Jakub Jelinek  <jakub@redhat.com>

	PR c++/85140
	* name-lookup.c (handle_namespace_attrs): Return early if attributes
	is error_mark_node.

	* g++.dg/cpp0x/gen-attrs-64.C: New test.


	Jakub

Comments

Jason Merrill April 3, 2018, 4:17 p.m. UTC | #1
OK.

On Tue, Apr 3, 2018 at 12:06 PM, Jakub Jelinek <jakub@redhat.com> wrote:

> Hi!
>
> If at least one attribute is errorneous, we get error_mark_node instead
> of the attributes list.
>
> The following patch fixes error recovery for that.  Bootstrapped/regtested
> on x86_64-linux and i686-linux, ok for trunk?
>
> 2018-04-03  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c++/85140
>         * name-lookup.c (handle_namespace_attrs): Return early if
> attributes
>         is error_mark_node.
>
>         * g++.dg/cpp0x/gen-attrs-64.C: New test.
>
> --- gcc/cp/name-lookup.c.jj     2018-03-30 20:37:36.219184285 +0200
> +++ gcc/cp/name-lookup.c        2018-04-03 10:15:22.670803588 +0200
> @@ -5044,6 +5044,9 @@ handle_namespace_attrs (tree ns, tree at
>    tree d;
>    bool saw_vis = false;
>
> +  if (attributes == error_mark_node)
> +    return false;
> +
>    for (d = attributes; d; d = TREE_CHAIN (d))
>      {
>        tree name = get_attribute_name (d);
> --- gcc/testsuite/g++.dg/cpp0x/gen-attrs-64.C.jj        2018-04-03
> 10:18:55.196780292 +0200
> +++ gcc/testsuite/g++.dg/cpp0x/gen-attrs-64.C   2018-04-03
> 10:17:57.064786662 +0200
> @@ -0,0 +1,4 @@
> +// PR c++/85140
> +// { dg-do compile { target c++11 } }
> +
> +namespace N alignas() {}       // { dg-error "expected" }
>
>         Jakub
>
diff mbox series

Patch

--- gcc/cp/name-lookup.c.jj	2018-03-30 20:37:36.219184285 +0200
+++ gcc/cp/name-lookup.c	2018-04-03 10:15:22.670803588 +0200
@@ -5044,6 +5044,9 @@  handle_namespace_attrs (tree ns, tree at
   tree d;
   bool saw_vis = false;
 
+  if (attributes == error_mark_node)
+    return false;
+
   for (d = attributes; d; d = TREE_CHAIN (d))
     {
       tree name = get_attribute_name (d);
--- gcc/testsuite/g++.dg/cpp0x/gen-attrs-64.C.jj	2018-04-03 10:18:55.196780292 +0200
+++ gcc/testsuite/g++.dg/cpp0x/gen-attrs-64.C	2018-04-03 10:17:57.064786662 +0200
@@ -0,0 +1,4 @@ 
+// PR c++/85140
+// { dg-do compile { target c++11 } }
+
+namespace N alignas() {}	// { dg-error "expected" }