After r16-6808-g4b0e94b394fa38, added was a loop around
attributes looking for an annotation attribute but
does not take into account the attribute might be
an error mark, so there is an ICE when trying to access
the get_attribute_name. This fixes the issue by breaking
out of the loop if the attribute is an error.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

        PR c++/124307

gcc/cp/ChangeLog:

        * parser.cc (cp_parser_base_specifier): Break from the loop
        if an attribute is an error mark.

gcc/testsuite/ChangeLog:

        * g++.dg/cpp0x/alignas24.C: New test.

Signed-off-by: Andrew Pinski <[email protected]>
---
 gcc/cp/parser.cc                       | 2 ++
 gcc/testsuite/g++.dg/cpp0x/alignas24.C | 8 ++++++++
 2 files changed, 10 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/alignas24.C

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index ffb22aa776f..8bd2368a8a4 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -31835,6 +31835,8 @@ cp_parser_base_specifier (cp_parser* parser)
       tree *pannotations = &annotations;
       for (tree attr = std_attrs; attr; attr = TREE_CHAIN (attr))
        {
+         if (error_operand_p (attr))
+           break;
          if (annotation_p (attr))
            {
              *pannotations = attr;
diff --git a/gcc/testsuite/g++.dg/cpp0x/alignas24.C 
b/gcc/testsuite/g++.dg/cpp0x/alignas24.C
new file mode 100644
index 00000000000..ef5b08213e8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alignas24.C
@@ -0,0 +1,8 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+// PR c++/124307
+
+// we used to ICE with alignas here.
+
+
+class : alignas // { dg-error "" }
-- 
2.43.0

Reply via email to