This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Old-C++ ABI inline method heuristic problem
- To: Nathan Sidwell <nathan at codesourcery dot com>
- Subject: Re: [PATCH] Old-C++ ABI inline method heuristic problem
- From: Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 9 May 2001 17:59:11 +0200
- Cc: aoliva at redhat dot com, bernds at redhat dot com, gcc-patches at gcc dot gnu dot org
- References: <20010509162334.P935@sunsite.ms.mff.cuni.cz> <3AF965E6.EBB1B8F2@codesourcery.com>
- Reply-To: Jakub Jelinek <jakub at redhat dot com>
On Wed, May 09, 2001 at 04:44:38PM +0100, Nathan Sidwell wrote:
> Jakub Jelinek wrote:
>
> > Particularly, if in a compilation unit other than the one which defines
> > first non-inline non-abstract virtual method some method is defined as
> > inline outside of the class definition and is used only in that compilation
> > unit, g++ does not emit the inline body of the function although it is used
> > (but it is not emitted in the class-exporting unit either, since it is not
> > defined there at all).
> If I understand you correctly, you have something like
>
> -- header file
> struct Foo{
> int baz ();
> virtual void keyFunc ();
> };
>
> ---- in some TUa
> inline int Foo::baz () {...}
> --- in some TUb
> void Foo::keyFunc () {...}
>
> Such code is illformed by 7.1.2/4
> If a function with external linkage is declared inline in one
> translation unit, it shall be declared inline in all translation
> units in which it appears; no diagnostic is required.
But the same paragraph requires the inline function to be defined only in
all translation units in which they are used.
In this case, it is only used in m.ii below, not in any other translation
unit (unless the declaration of method in the class definition counts as
usage).
Jakub
# 1 "m.C"
# 1 "m.h" 1
struct B
{
virtual ~B() {}
};
struct A : public B
{
A();
~A();
inline void foo(void);
void bar(void);
};
# 1 "m.C" 2
inline void A::foo(void)
{
static int i;
i++;
}
void A::bar()
{
foo();
}
int main()
{
}
# 1 "n.C"
# 1 "m.h" 1
struct B
{
virtual ~B() {}
};
struct A : public B
{
A();
~A();
inline void foo(void);
void bar(void);
};
# 1 "n.C" 2
A::A()
{
}
A::~A()
{
}