public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Marek Polacek <polacek@redhat.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>,
	       Joseph Myers <joseph@codesourcery.com>
Subject: C PATCH for c/79730, ICE on invalid with DECL_HARD_REGISTER
Date: Wed, 29 Mar 2017 18:23:00 -0000	[thread overview]
Message-ID: <20170329180701.GT3172@redhat.com> (raw)

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  <polacek@redhat.com>

	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

             reply	other threads:[~2017-03-29 18:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 18:23 Marek Polacek [this message]
2017-03-29 19:31 ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170329180701.GT3172@redhat.com \
    --to=polacek@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).