From patchwork Fri Mar 10 11:48:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 737376 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vflrt28qQz9s7p for ; Fri, 10 Mar 2017 22:48:29 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="HUXb3x/b"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=nGTm0nOmcDIQVTLGsKOQXCwXqtLQhvZTy1A9Au8dre3iCtxTjYUD9 uwpdmwER6mWTriN7dUPMmADZbG5fxxA3YW+G3UsPdjmxkDFm9yKGToOUThHkjB6T Mgzng0lJN3QgJ8GKUCl67393t5n4ACFt8KFnDKOwc3twHV0jzKzqws= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=6ceodVbzmFxNMWchbuzzHgUwjhw=; b=HUXb3x/bGsS0V8lz9Lt+ rMBwVQ+3YKFm6F32vqLsqf+Dno7P244UGdQszkLa5Q7PTn7LtDXYobBoBR1b5lWS fbF75Y7ghiGy59YgpaVzk2K77n7R0CFW0JpQG3iRybYBlEtF9unpDr8ZH5uY/emY nuktLse3tbyKLwjGdErSgD8= Received: (qmail 65748 invoked by alias); 10 Mar 2017 11:48:21 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 65727 invoked by uid 89); 10 Mar 2017 11:48:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Mar 2017 11:48:18 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 745589D404 for ; Fri, 10 Mar 2017 11:48:15 +0000 (UTC) Received: from redhat.com (ovpn-204-150.brq.redhat.com [10.40.204.150]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ABmCXM008885 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 10 Mar 2017 06:48:14 -0500 Date: Fri, 10 Mar 2017 12:48:11 +0100 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: C++ PATCH to fix segv with [[noreturn]] (PR c++/79967) Message-ID: <20170310114811.GK3172@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) Not sure of the validity of the test, but clang accepts it and so do we, with this patch. We shouldn't attempt to dereference a pointer that could be NULL without checking it first. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2017-03-10 Marek Polacek PR c++/79967 * decl.c (grokdeclarator): Check ATTRLIST before dereferencing it. * g++.dg/cpp0x/gen-attrs-63.C: New test. Marek diff --git gcc/cp/decl.c gcc/cp/decl.c index 3e7316f..b51ef8a 100644 --- gcc/cp/decl.c +++ 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 gcc/testsuite/g++.dg/cpp0x/gen-attrs-63.C gcc/testsuite/g++.dg/cpp0x/gen-attrs-63.C index e69de29..05f53e3 100644 --- gcc/testsuite/g++.dg/cpp0x/gen-attrs-63.C +++ 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 (); }