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: C++: Anticipated declaration of builtins.


Roger Sayle <roger@eyesopen.com> writes:

| Hi Gaby,
| 
| > 1) Shouldn't we pre-declare the function at global scope, then
| >    do a using-declaration at the standard scope?
| 
| The problem here is that they need to be treated as two independent
| pre-declarations.  If a prototype or declaration is given for
| one, it does not automatically anticipate/declare the other.  Hence,
| we require separate DECLs with independent DECL_ANTICIPATED flags.

Hmm, why do we need to have two independent declarations for the same
builtin? 

| Similarly, the user-provided declaration/prototype in one namespace
| could be compatible with the predeclared type, and hence use the
| builtin's functionality, but the declaration given in the other
| namespace incompatible, overrides the anticipated functionality
| and providing it's own definition, DECL_RTL, etc...

If we have the same builtin declared twice with possibly two
incompatible declarations, it occurs to me that we're calling for
trouble.  Is there any case where that could be useful?

| > 2) Why doesn't the second call to builtin_function_1() specify
| >    global_namespace instead of NULL_TREE?  I think specifying
| >    global_namespace should be the way to go.  What I am missing?
| 
| For this I have no good answer.  The original code used NULL_TREE
| when I added the additional call to also anticipate the declaration
| in the std:: namespace.  I've no problem with you changing it if
| that's more correct thing to do, and it passes regression checking.

The point is that I have been reworking some part of th name lookup
machinery, and that particular behaviour crashes the compiler until I
realized that declarations (of builtins) in the outer space is no good.
If they  are supposed to be pre-declared at the global scope (as the
comment indicates), then their DECL_CONTEXT should point to
global_namespace.  I'll make that change, once I understand the other
issue.

Thanks,

-- Gaby


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