* C PATCH for c/79730, ICE on invalid with DECL_HARD_REGISTER
@ 2017-03-29 18:23 Marek Polacek
2017-03-29 19:31 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2017-03-29 18:23 UTC (permalink / raw)
To: GCC Patches, Joseph Myers
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: C PATCH for c/79730, ICE on invalid with DECL_HARD_REGISTER
2017-03-29 18:23 C PATCH for c/79730, ICE on invalid with DECL_HARD_REGISTER Marek Polacek
@ 2017-03-29 19:31 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2017-03-29 19:31 UTC (permalink / raw)
To: Marek Polacek, GCC Patches, Joseph Myers
On 03/29/2017 12:07 PM, Marek Polacek wrote:
> 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.
OK.
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-29 19:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-29 18:23 C PATCH for c/79730, ICE on invalid with DECL_HARD_REGISTER Marek Polacek
2017-03-29 19:31 ` Jeff Law
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).