aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2010-03-26 23:52:09 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2010-03-26 23:52:09 +0000
commit10e76c1a45d1efa0f4637ec4bb09fbc6005ed3fd (patch)
tree8dd23f7d006e9f449c212ce5cea214baccf360b6 /gcc
parentc6cc83d0c956ff38234275106c582edac67d3e39 (diff)
downloadgcc-10e76c1a45d1efa0f4637ec4bb09fbc6005ed3fd.zip
gcc-10e76c1a45d1efa0f4637ec4bb09fbc6005ed3fd.tar.gz
gcc-10e76c1a45d1efa0f4637ec4bb09fbc6005ed3fd.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/c-decl.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/parm-impl-decl-3.c28
4 files changed, 49 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 513c090..eb2928d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2010-03-26 Joseph Myers <joseph@codesourcery.com>
+
+ 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 <jakub@redhat.com>
* var-tracking.c (vt_expand_loc_callback): Don't run
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index fed04dc..b6ff3f4 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 3ed0e1c..01c513b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-03-26 Joseph Myers <joseph@codesourcery.com>
+
+ PR c/43381
+ * gcc.dg/parm-impl-decl-3.c: New test.
+
2010-03-26 Jason Merrill <jason@redhat.com>
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 0000000..b3941b9
--- /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 <joseph@codesourcery.com> */
+/* { 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; }