From 10fa8dfb3a13443006563fd14af64d4751ebb7fb Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Wed, 29 Mar 2017 23:40:36 +0000 Subject: [PATCH] re PR c/79730 (ICE tree check: expected var_decl, have function_decl in finish_decl, at c/c-decl.c:5063) PR c/79730 * c-decl.c (finish_decl): Check VAR_P. * gcc.dg/pr79730.c: New test. From-SVN: r246578 --- gcc/c/ChangeLog | 5 +++++ gcc/c/c-decl.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr79730.c | 6 ++++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr79730.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 08a5b9ae2d7..b64d9cfe905 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2017-03-29 Marek Polacek + + PR c/79730 + * c-decl.c (finish_decl): Check VAR_P. + 2017-03-27 Jakub Jelinek PR middle-end/80162 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index a0dc5bc0bee..53c390c9e48 100644 --- a/gcc/c/c-decl.c +++ b/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 a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index acbfee9929b..d8e6f875c42 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-03-29 Marek Polacek + + PR c/79730 + * gcc.dg/pr79730.c: New test. + 2017-03-29 Jerry DeLisle PR libgfortran/78670 diff --git a/gcc/testsuite/gcc.dg/pr79730.c b/gcc/testsuite/gcc.dg/pr79730.c new file mode 100644 index 00000000000..497823a486c --- /dev/null +++ b/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" } */ -- 2.30.2