This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: Anonymous Namespaces


Chris Lattner <sabre@nondot.org> writes:

| Gabriel Dos Reis wrote:
| > | > Yes because that is not the way C++ works, anonymous namespaces only
| > | > give an unique name for that translation unit and that is it; it does
| > | > not change the linkage of the symbol at all.
| > |
| > | Is there any harm is doing so?
| 
| > Yes. The second phase of two-phase name lookup ignores functions with
| > internal linkages.  Also, entities with internal linkage cannot be
| > used as template arguments.
| 
| With the LLVM G++ front-end, all entities declared in an anonymous
| namespace are emitted with internal linkage, including any related RTTI
| info, vtables, etc.

Do you implement the rest of the C++ language (e.g. proper two-phase
name lookup)? (Note that exported templates also interact with names
with internal linkage, but granted, we don't have export yet).

As I explained in another message, if the issue is this particular
optimization, the right thing to do is teach the programmed inliner
about unnamed namespace instead of fiddling with the semantics.  

And if "static" is what you want; just use "static" :-)

| This has absolutely no effect on the front-end, we handle it in our
| version of "expand".

Hmm, are we talking about the C++ front-end?  Notice that anything I
said about has to do with the C++ front-end, not with the middle-end
or the back-end. 

-- Gaby


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