From 10e76c1a45d1efa0f4637ec4bb09fbc6005ed3fd Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Fri, 26 Mar 2010 23:52:09 +0000 Subject: [PATCH] re PR c/43381 (infinite loop in gcc.dg/parm-impl-decl-1.c with -g) PR c/43381 * c-decl.c (get_parm_info): Assert that decl going in OTHERS has a nested binding iff it is a FUNCTION_DECL. (store_parm_decls_newstyle): Pass nested=true to bind for FUNCTION_DECLs amongst parameters. testsuite: * gcc.dg/parm-impl-decl-3.c: New test. From-SVN: r157766 --- gcc/ChangeLog | 8 +++++++ gcc/c-decl.c | 9 +++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/parm-impl-decl-3.c | 28 +++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/parm-impl-decl-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 513c09071f8..eb2928df856 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2010-03-26 Joseph Myers + + PR c/43381 + * c-decl.c (get_parm_info): Assert that decl going in OTHERS has a + nested binding iff it is a FUNCTION_DECL. + (store_parm_decls_newstyle): Pass nested=true to bind for + FUNCTION_DECLs amongst parameters. + 2010-03-26 Jakub Jelinek * var-tracking.c (vt_expand_loc_callback): Don't run diff --git a/gcc/c-decl.c b/gcc/c-decl.c index fed04dca9e9..b6ff3f476e6 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -6303,6 +6303,11 @@ get_parm_info (bool ellipsis) type itself. FUNCTION_DECLs appear when there is an implicit function declaration in the parameter list. */ + /* When we reinsert this decl in the function body, we need + to reconstruct whether it was marked as nested. */ + gcc_assert (TREE_CODE (decl) == FUNCTION_DECL + ? b->nested + : !b->nested); TREE_CHAIN (decl) = others; others = decl; /* fall through */ @@ -7624,7 +7629,9 @@ store_parm_decls_newstyle (tree fndecl, const struct c_arg_info *arg_info) DECL_CONTEXT (decl) = current_function_decl; if (DECL_NAME (decl)) bind (DECL_NAME (decl), decl, current_scope, - /*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION); + /*invisible=*/false, + /*nested=*/(TREE_CODE (decl) == FUNCTION_DECL), + UNKNOWN_LOCATION); } /* And all the tag declarations. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3ed0e1c6a1f..01c513b9e63 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-03-26 Joseph Myers + + PR c/43381 + * gcc.dg/parm-impl-decl-3.c: New test. + 2010-03-26 Jason Merrill PR c++/43509 diff --git a/gcc/testsuite/gcc.dg/parm-impl-decl-3.c b/gcc/testsuite/gcc.dg/parm-impl-decl-3.c new file mode 100644 index 00000000000..b3941b92b62 --- /dev/null +++ b/gcc/testsuite/gcc.dg/parm-impl-decl-3.c @@ -0,0 +1,28 @@ +/* Like parm-impl-decl-1.c, but with -g. PR 43381. */ +/* Origin: Joseph Myers */ +/* { dg-do compile } */ +/* { dg-options "-g" } */ + +int +foo (int __attribute__ ((__mode__ (vector_size(8)))) i) /* { dg-warning "'__mode__' attribute ignored" } */ +{ + return (long long) i; +} + +int f (int [sizeof(g())]); +int f1 (int [sizeof(g1())]); + +int g () { return 1; } + +int +h (int (*p)[sizeof(i())]) +{ + int g2 (), g3 (); + return (*p)[0] + g3() + g2(); +} + +int i () { return 2; } + +int f2 (int [sizeof(g2())]); +int f3 (int [sizeof(g3())]); +int g3 () { return 4; }