From 455d833cd8ea14eec356e0f85a3a7e173592ece8 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Fri, 10 Mar 2017 15:36:00 +0000 Subject: [PATCH] re PR c++/79967 (ICE on non-type template argument declared noreturn) 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 | 5 +++++ gcc/cp/decl.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/gen-attrs-63.C | 12 ++++++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/gen-attrs-63.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d3871aada43..69b49e60b36 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-03-10 Marek Polacek + + PR c++/79967 + * decl.c (grokdeclarator): Check ATTRLIST before dereferencing it. + 2017-03-10 Jakub Jelinek PR c++/79899 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2a97ffc6582..bf6f0eb56be 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a7dae3d232c..bd5919f9649 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-03-10 Marek Polacek + + PR c++/79967 + * g++.dg/cpp0x/gen-attrs-63.C: New test. + 2017-03-10 Jakub Jelinek 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 index 00000000000..05f53e306c1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/gen-attrs-63.C @@ -0,0 +1,12 @@ +// PR c++/79967 +// { dg-do compile { target c++11 } } + +template +struct A +{ + int g () { f (); return 0; } +}; + +void f (); + +void g (A a) { a.g (); } -- 2.30.2