]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/58584 ([c++11] ICE with invalid argument for alignas)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 3 Oct 2013 22:50:59 +0000 (22:50 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 3 Oct 2013 22:50:59 +0000 (22:50 +0000)
/cp
2013-10-04  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58584
* decl2.c (save_template_attributes): Handle error_mark_node as
*attr_p argument.
(cp_check_const_attributes): Likewise for attributes.
* parser.c (cp_parser_std_attribute_spec): When alignas_expr is an
error_mark_node call cp_parser_skip_to_end_of_statement.

/testsuite
2013-10-04  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/58584
* g++.dg/cpp0x/gen-attrs-55.C: New.

From-SVN: r203193

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/gen-attrs-55.C [new file with mode: 0644]

index cd75094273182ca3d74cd9aae0473f0204fb8154..f618475d85bcb27d742ab48f4aaaff346bb32e11 100644 (file)
@@ -1,3 +1,12 @@
+2013-10-04  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58584
+       * decl2.c (save_template_attributes): Handle error_mark_node as
+       *attr_p argument.
+       (cp_check_const_attributes): Likewise for attributes.
+       * parser.c (cp_parser_std_attribute_spec): When alignas_expr is an
+       error_mark_node call cp_parser_skip_to_end_of_statement.
+
 2013-10-03  Easwaran Raman  <eraman@google.com>
 
        PR c++/33911
index 4ac9445ecc999d9879d3de39aaa95e419807a049..53e6bc9da1b7d0f4191c3f3bd71609091b4c7a1e 100644 (file)
@@ -1218,10 +1218,12 @@ splice_template_attributes (tree *attr_p, tree decl)
 static void
 save_template_attributes (tree *attr_p, tree *decl_p)
 {
-  tree late_attrs = splice_template_attributes (attr_p, *decl_p);
   tree *q;
-  tree old_attrs = NULL_TREE;
 
+  if (attr_p && *attr_p == error_mark_node)
+    return;
+
+  tree late_attrs = splice_template_attributes (attr_p, *decl_p);
   if (!late_attrs)
     return;
 
@@ -1230,7 +1232,7 @@ save_template_attributes (tree *attr_p, tree *decl_p)
   else
     q = &TYPE_ATTRIBUTES (*decl_p);
 
-  old_attrs = *q;
+  tree old_attrs = *q;
 
   /* Merge the late attributes at the beginning with the attribute
      list.  */
@@ -1318,6 +1320,9 @@ cp_reconstruct_complex_type (tree type, tree bottom)
 static void
 cp_check_const_attributes (tree attributes)
 {
+  if (attributes == error_mark_node)
+    return;
+
   tree attr;
   for (attr = attributes; attr; attr = TREE_CHAIN (attr))
     {
index 42b4e60219ee2527d6c43b7f59c7849e9c30f441..1a9d6b9dfb1d8050fc2536f04a5cf997fc1c292b 100644 (file)
@@ -21458,6 +21458,8 @@ cp_parser_std_attribute_spec (cp_parser *parser)
          alignas_expr =
            cp_parser_assignment_expression (parser, /*cast_p=*/false,
                                             /**cp_id_kind=*/NULL);
+         if (alignas_expr == error_mark_node)
+           cp_parser_skip_to_end_of_statement (parser);
          if (alignas_expr == NULL_TREE
              || alignas_expr == error_mark_node)
            return alignas_expr;
index b423b92620a382f699495729882eb3648a577021..d631f0f5775c8096df56f1ce90cde381a920c46c 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-04  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/58584
+       * g++.dg/cpp0x/gen-attrs-55.C: New.
+
 2013-10-03  Easwaran Raman  <eraman@google.com>
 
        PR c++/33911
diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-55.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-55.C
new file mode 100644 (file)
index 0000000..c4e6dea
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/58584
+// { dg-do compile { target c++11 } }
+
+struct A
+{
+  int i alignas(this);  // { dg-error "17:invalid use of 'this'" }
+};
+
+template<int> struct B
+{
+  int j alignas(this);  // { dg-error "17:invalid use of 'this'" }
+};