re PR c++/2781 (bad code generated for reference call with -O2 (regression from 2.95))

cp:
	PR c++/2781
	* optimize.c (update_cloned_parm): Copy addressability and other
	flags.
testsuite:
	* g++.old-deja/g++.other/optimize1.C: New test.

From-SVN: r42344
This commit is contained in:
Nathan Sidwell 2001-05-20 13:41:34 +00:00 committed by Nathan Sidwell
parent 3b82c24918
commit d30a825a20
4 changed files with 88 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2001-05-20 Nathan Sidwell <nathan@codesourcery.com>
PR c++/2781
* optimize.c (update_cloned_parm): Copy addressability and other
flags.
2001-05-20 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* pt.c (determine_specialization): Ignore artificial functions.

View File

@ -1021,12 +1021,19 @@ update_cloned_parm (parm, cloned_parm)
tree cloned_parm;
{
DECL_ABSTRACT_ORIGIN (cloned_parm) = parm;
/* We may have taken its address. */
TREE_ADDRESSABLE (cloned_parm) = TREE_ADDRESSABLE (parm);
/* The definition might have different constness. */
TREE_READONLY (cloned_parm) = TREE_READONLY (parm);
TREE_USED (cloned_parm) = TREE_USED (parm);
/* The name may have changed from the declaration. */
DECL_NAME (cloned_parm) = DECL_NAME (parm);
DECL_SOURCE_FILE (cloned_parm) = DECL_SOURCE_FILE (parm);
DECL_SOURCE_LINE (cloned_parm) = DECL_SOURCE_LINE (parm);
}
/* FN is a function that has a complete body. Clone the body as

View File

@ -1,3 +1,7 @@
2001-05-20 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.other/optimize1.C: New test.
2001-05-20 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* g++.old-deja/g++.pt/spec41.C: New test.

View File

@ -0,0 +1,70 @@
// Special g++ Options: -O2
//
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 18 May 2001 <nathan@codesourcery.com>
// Bug 2781. We forgot to copy addressability information when
// cloning.
struct B
{
B(int v1);
void Member (int v1);
static void Static (int v1);
};
struct D : B
{
D (int v1);
};
void xswap(int& x1) ;
int xxx = 0;
B::B(int v1)
{
xswap(v1);
xxx = v1;
}
void B::Member(int v1)
{
xswap(v1);
xxx = v1;
}
void B::Static(int v1)
{
xswap(v1);
xxx = v1;
}
D::D(int v1)
: B (v1)
{
}
void xswap (int& x1) { x1 = 2; }
int main ()
{
B p (1);
if (xxx != 2)
return 1;
D q (1);
if (xxx != 2)
return 2;
p.Member (1);
if (xxx != 2)
return 3;
p.Static (1);
if (xxx != 2)
return 4;
return 0;
}