]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Fix ICE with error mark for an attribute [PR124307]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sun, 15 Mar 2026 06:36:56 +0000 (23:36 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 16 Mar 2026 22:07:00 +0000 (15:07 -0700)
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.
 * v3: small formating changes.

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 <andrew.pinski@oss.qualcomm.com>
gcc/cp/parser.cc
gcc/testsuite/g++.dg/cpp0x/alignas24.C [new file with mode: 0644]

index ffb22aa776f6c45fc1b9efe184445f76bd50c2de..51d26cecc4bc27d7319e6dfc8a124b3be5013709 100644 (file)
@@ -31830,7 +31830,7 @@ 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)
     {
       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 (file)
index 0000000..2966a9c
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/124307
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+class : alignas // { dg-error "" }