re PR c++/79967 (ICE on non-type template argument declared noreturn)
authorMarek Polacek <polacek@redhat.com>
Fri, 10 Mar 2017 15:36:00 +0000 (15:36 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 10 Mar 2017 15:36:00 +0000 (15:36 +0000)
PR c++/79967
* decl.c (grokdeclarator): Check ATTRLIST before dereferencing it.

* g++.dg/cpp0x/gen-attrs-63.C: New test.

From-SVN: r246039

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

index d3871aada43a41f8e6615c7ecfcc2c9ea6361c8d..69b49e60b36e3d7f0895fb182a8446d0a11039e7 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-10  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/79967
+       * decl.c (grokdeclarator): Check ATTRLIST before dereferencing it.
+
 2017-03-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/79899
index 2a97ffc6582d5d8d813b87a6608d203eade688eb..bf6f0eb56bea8a6aca0c8ddfa113377e420286e3 100644 (file)
@@ -11402,7 +11402,8 @@ grokdeclarator (const cp_declarator *declarator,
 
   if (declarator
       && declarator->kind == cdk_id
-      && declarator->std_attributes)
+      && declarator->std_attributes
+      && attrlist != NULL)
     /* [dcl.meaning]/1: The optional attribute-specifier-seq following
        a declarator-id appertains to the entity that is declared.  */
     *attrlist = chainon (*attrlist, declarator->std_attributes);
index a7dae3d232cd8e8236c6c6978aad15de36f8033a..bd5919f96498752c36a9997a8d718b386a81a458 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-10  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/79967
+       * g++.dg/cpp0x/gen-attrs-63.C: New test.
+
 2017-03-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/79899
diff --git a/gcc/testsuite/g++.dg/cpp0x/gen-attrs-63.C b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-63.C
new file mode 100644 (file)
index 0000000..05f53e3
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/79967
+// { dg-do compile { target c++11 } }
+
+template <void f [[noreturn]]()>
+struct A
+{
+  int g () { f (); return 0; }
+};
+
+void f ();
+
+void g (A<f> a) { a.g (); }