re PR c++/2823 (kde2/artsd miscompilation (part 1))

cp:
	PR g++/2823
	* semantics.c (expand_body): Don't optimize thunks.
testsuite:
	* g++.old-deja/g++.other/optimize2.C: New file.

From-SVN: r42650
This commit is contained in:
Nathan Sidwell 2001-05-26 19:20:06 +00:00 committed by Nathan Sidwell
parent 3d04c7c664
commit 87d9ac4914
4 changed files with 90 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2001-05-26 Nathan Sidwell <nathan@codesourcery.com>
PR g++/2823
* semantics.c (expand_body): Don't optimize thunks.
2001-05-25 Sam TH <sam@uchicago.edu>
* cp-tree.h lex.h: Fix header include guards.

View file

@ -2397,8 +2397,13 @@ expand_body (fn)
timevar_push (TV_INTEGRATION);
/* Optimize the body of the function before expanding it. */
optimize_function (fn);
/* Optimize the body of the function before expanding it. We do not
optimize thunks, as (1) the backend tries to optimize the call to
the thunkee, (b) the tree based inliner breaks that optimization,
(c) virtual functions are rarely inlineable, and (d)
ASM_OUTPUT_MI_THUNK is there to DTRT anyway. */
if (!DECL_THUNK_P (fn))
optimize_function (fn);
timevar_pop (TV_INTEGRATION);
timevar_push (TV_EXPAND);

View file

@ -1,3 +1,7 @@
2001-05-26 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.other/optimize2.C: New file.
2001-05-25 Diego Novillo <dnovillo@redhat.com>
* gcc.c-torture/compile/20010518-2.c: New file.

View file

@ -0,0 +1,74 @@
// Special g++ Options: -O2
//
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 26 May 2001 <nathan@codesourcery.com>
// Bug 2823. Inlineing the body of a thunk broke things. But that's
// rarely a sensible thing to do anyway.
#include <cstdio>
#include <cstdlib>
int objCount = 0;
struct Thing
{
int count;
Thing ();
Thing (Thing const &src);
~Thing ();
};
Thing::Thing ()
:count (0)
{
objCount++;
std::printf ("%p %s\n", (void *)this,__PRETTY_FUNCTION__);
}
Thing::Thing (Thing const &src)
:count (0)
{
objCount++;
std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
}
Thing::~Thing ()
{
std::printf ("%p %s\n", (void *)this, __PRETTY_FUNCTION__);
if (count)
std::abort ();
count--;
objCount--;
}
void x(Thing name)
{
// destruct name here
}
class Base
{
public:
virtual void test(const Thing& s) = 0;
};
class Impl : virtual public Base
{
public:
virtual void test(const Thing& s)
{
x(s); // copy construct temporary
}
};
int main()
{
Impl *impl = new Impl();
impl->test( Thing ()); // This will use a thunk
return objCount != 0;
}