typedef-named class member functions can be public

Alexandre Oliva aoliva@redhat.com
Fri Jul 5 14:02:00 GMT 2002


On Jul  5, 2002, Alexandre Oliva <aoliva@redhat.com> wrote:

> On Jul  5, 2002, Mark Mitchell <mark@codesourcery.com> wrote:

>> In any case, the patch isn't correct, if I understand it correctly.
>> You need to back and fix the linkage of the functions when the typedef
>> is processed -- not later when the functions are defined.

> Hmm...  Sounds reasonable, I'll try to do that.  Thanks,

Hmm...  But why does it make any difference?  I mean, linkage will
only make a difference if the member function is actually defined
outside the class body, no?

BTW, I've just noticed that static data members are always marked as
TREE_PUBLIC, regardless of the linkage of the enclosing class type.

[cp/decl.c] grokvardecl():
[...]
  /* In class context, static means one per class,
     public access, and static storage.  */
  if (DECL_CLASS_SCOPE_P (decl))
    {
      TREE_PUBLIC (decl) = 1;
      TREE_STATIC (decl) = 1;
      DECL_EXTERNAL (decl) = 0;
    }

Is this not wrong in case the class has no or internal linkage?
Problem is, when we get to the point of knowing whether the enclosing
class has linkage, we've already created the decls of all its members.
Would it be reasonable to just set the TREE_PUBLIC bit in all function
or static-data class members?  Or would this somehow break for member
functions?

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer



More information about the Gcc-patches mailing list