From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129462 invoked by alias); 29 Mar 2017 18:07:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 129441 invoked by uid 89); 29 Mar 2017 18:07:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,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; Wed, 29 Mar 2017 18:07:05 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 6422B3DBF7; Wed, 29 Mar 2017 18:07:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6422B3DBF7 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=polacek@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6422B3DBF7 Received: from redhat.com (ovpn-204-110.brq.redhat.com [10.40.204.110]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2TI72BU031562 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 29 Mar 2017 14:07:04 -0400 Date: Wed, 29 Mar 2017 18:23:00 -0000 From: Marek Polacek To: GCC Patches , Joseph Myers Subject: C PATCH for c/79730, ICE on invalid with DECL_HARD_REGISTER Message-ID: <20170329180701.GT3172@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-SW-Source: 2017-03/txt/msg01481.txt.bz2 DECL_HARD_REGISTER only expects a VAR_DECL, so check for that first (C++'s make_rtl_for_nonlocal_decl does that, too). Bootstrapped/regtested on x86_64-linux, ok for trunk? 2017-03-29 Marek Polacek PR c/79730 * c-decl.c (finish_decl): Check VAR_P. * gcc.dg/pr79730.c: New test. diff --git gcc/c/c-decl.c gcc/c/c-decl.c index a0dc5bc..53c390c 100644 --- gcc/c/c-decl.c +++ gcc/c/c-decl.c @@ -5066,7 +5066,7 @@ finish_decl (tree decl, location_t init_loc, tree init, when a tentative file-scope definition is seen. But at end of compilation, do output code for them. */ DECL_DEFER_OUTPUT (decl) = 1; - if (asmspec && C_DECL_REGISTER (decl)) + if (asmspec && VAR_P (decl) && C_DECL_REGISTER (decl)) DECL_HARD_REGISTER (decl) = 1; rest_of_decl_compilation (decl, true, 0); } diff --git gcc/testsuite/gcc.dg/pr79730.c gcc/testsuite/gcc.dg/pr79730.c index e69de29..497823a 100644 --- gcc/testsuite/gcc.dg/pr79730.c +++ gcc/testsuite/gcc.dg/pr79730.c @@ -0,0 +1,6 @@ +/* PR c/79730 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ + +register int x() asm (""); /* { dg-error "invalid storage class" } */ +register float y() asm (""); /* { dg-error "invalid storage class" } */ Marek