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 <ja...@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