This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] Old-C++ ABI inline method heuristic problem


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()
{
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]