From e8112eacf708ba210c298d2419266ddc3c632aad Mon Sep 17 00:00:00 2001 From: Zak Kipling Date: Sat, 13 Nov 2004 15:09:08 -0800 Subject: [PATCH] re PR target/18300 (Infinite loop when passing object with 3+ base classes by value) PR target/18300 * config/i386/i386.c (classify_argument): Fix infinite loop when passing object with 3 or more base classes by value. From-SVN: r90600 --- gcc/ChangeLog | 8 +++++++- gcc/config/i386/i386.c | 12 ++++++------ gcc/testsuite/g++.dg/other/infloop-1.C | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.dg/other/infloop-1.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3630a10d720..ba8cdf2bff0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-11-13 Zak Kipling + + PR target/18300 + * config/i386/i386.c (classify_argument): Fix infinite loop when + passing object with 3 or more base classes by value. + 2004-11-13 Eric Botcazou * doc/md.texi (constraints) <% modifier>: Mention that it is @@ -79,7 +85,7 @@ * doc/rtl.texi (INSN_DEAD_CODE_P, REG_LOOP_TEST_P): Remove. 2004-11-13 James A. Morrison - Eric Botcazou + Eric Botcazou PR target/18230 * config/sparc/sparc.c (sparc_rtx_costs): Handle the NAND vector diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 5f45e4295e8..089957e830b 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2117,10 +2117,10 @@ classify_argument (enum machine_mode mode, tree type, if (TYPE_BINFO (type)) { tree binfo, base_binfo; - int i; + int basenum; - for (binfo = TYPE_BINFO (type), i = 0; - BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) + for (binfo = TYPE_BINFO (type), basenum = 0; + BINFO_BASE_ITERATE (binfo, basenum, base_binfo); basenum++) { int num; int offset = tree_low_cst (BINFO_OFFSET (base_binfo), 0) * 8; @@ -2204,10 +2204,10 @@ classify_argument (enum machine_mode mode, tree type, if (TYPE_BINFO (type)) { tree binfo, base_binfo; - int i; + int basenum; - for (binfo = TYPE_BINFO (type), i = 0; - BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) + for (binfo = TYPE_BINFO (type), basenum = 0; + BINFO_BASE_ITERATE (binfo, basenum, base_binfo); basenum++) { int num; int offset = tree_low_cst (BINFO_OFFSET (base_binfo), 0) * 8; diff --git a/gcc/testsuite/g++.dg/other/infloop-1.C b/gcc/testsuite/g++.dg/other/infloop-1.C new file mode 100644 index 00000000000..6c851c7e5e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/infloop-1.C @@ -0,0 +1,16 @@ +// PR 18300: This sends old compilers into an infinite loop on x86_64 +// Testcase and patch contributed by Zak Kipling + +struct base1 { }; +struct base2 { }; +struct base3 { }; + +struct derived : base1, base2, base3 { }; + +void foo(derived); + +int main() +{ + foo(derived()); +} + -- 2.30.2