On 3/16/26 9:11 AM, Marek Polacek wrote:
On Sun, Mar 15, 2026 at 07:48:43PM -0700, Andrew Pinski wrote:
After r16-6808-g4b0e94b394fa38, we started to ICE when the
std_attrs was error_mark_node. This fixes the problem by
checking if it was an error_mark_node before looking for
annotations.

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

Changes since v1:
  * v2: Move the check for error mark earlier.

        PR c++/124307

gcc/cp/ChangeLog:

        * parser.cc (cp_parser_base_specifier): Check for
        error mark like checking for non-nullness on the
        attribute.

gcc/testsuite/ChangeLog:

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

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

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index ffb22aa776f..a8ec3db5884 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -31830,7 +31830,8 @@ cp_parser_base_specifier (cp_parser* parser)
    tree std_attrs = cp_parser_std_attribute_spec_seq (parser);
    tree annotations = NULL_TREE;
- if (std_attrs != NULL_TREE)
+  if (std_attrs != NULL_TREE
+      && std_attrs != error_mark_node)

This looks like it can fit on one line.

      {
        tree *pannotations = &annotations;
        for (tree attr = std_attrs; attr; attr = TREE_CHAIN (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

This should be the first line.

+
+// we used to ICE with alignas here.
+
+

And I think we can just drop the three lines above.

OK with these tweaks.

+class : alignas // { dg-error "" }
--
2.43.0


Marek


Reply via email to