Enea Zaffanella | 9 Jul 10:57 2012
Picon

The DeclContext of block-scope function declarations.

Consider the following program:

$ cat block.cc
namespace N {

void f() {
   extern int var;     // #1
   extern void g(int); // #2
   g(var);
}

class S {
   friend void h();    // #3
};

} // namespace N

Function N::f() declares extern function `g(int)' and int object `var'.
In the AST generated by clang, these two block-scope declarations have 
function N::f() as their (semantic and lexical) DeclContext.

However, C++11 3.5p7 says:

   "When a block scope declaration of an entity with linkage is not
    found to refer to some other declaration, then that entity is a
    member of the innermost enclosing namespace. However such a
    declaration does not introduce the member name in its
    namespace scope."

This seems to suggest that both `g(int)' and `var' should have namespace 
(Continue reading)

Enea Zaffanella | 13 Jul 09:17 2012
Picon

Re: The DeclContext of block-scope function declarations.

Ping.

On 07/09/2012 10:57 AM, Enea Zaffanella wrote:
> Consider the following program:
>
> $ cat block.cc
> namespace N {
>
> void f() {
>     extern int var;     // #1
>     extern void g(int); // #2
>     g(var);
> }
>
> class S {
>     friend void h();    // #3
> };
>
> } // namespace N
>
>
> Function N::f() declares extern function `g(int)' and int object `var'.
> In the AST generated by clang, these two block-scope declarations have
> function N::f() as their (semantic and lexical) DeclContext.
>
> However, C++11 3.5p7 says:
>
>     "When a block scope declaration of an entity with linkage is not
>      found to refer to some other declaration, then that entity is a
>      member of the innermost enclosing namespace. However such a
(Continue reading)

Enea Zaffanella | 31 Jul 10:51 2012
Picon

Re: The DeclContext of block-scope function declarations.

Ping^2.

On 07/13/2012 09:17 AM, Enea Zaffanella wrote:
> Ping.
>
> On 07/09/2012 10:57 AM, Enea Zaffanella wrote:
>> Consider the following program:
>>
>> $ cat block.cc
>> namespace N {
>>
>> void f() {
>>      extern int var;     // #1
>>      extern void g(int); // #2
>>      g(var);
>> }
>>
>> class S {
>>      friend void h();    // #3
>> };
>>
>> } // namespace N
>>
>>
>> Function N::f() declares extern function `g(int)' and int object `var'.
>> In the AST generated by clang, these two block-scope declarations have
>> function N::f() as their (semantic and lexical) DeclContext.
>>
>> However, C++11 3.5p7 says:
>>
(Continue reading)

Douglas Gregor | 1 Aug 19:09 2012
Picon

Re: The DeclContext of block-scope function declarations.


On Jul 9, 2012, at 1:57 AM, Enea Zaffanella <zaffanella@...> wrote:

> Consider the following program:
> 
> $ cat block.cc
> namespace N {
> 
> void f() {
>   extern int var;     // #1
>   extern void g(int); // #2
>   g(var);
> }
> 
> class S {
>   friend void h();    // #3
> };
> 
> } // namespace N
> 
> 
> Function N::f() declares extern function `g(int)' and int object `var'.
> In the AST generated by clang, these two block-scope declarations have 
> function N::f() as their (semantic and lexical) DeclContext.
> 
> However, C++11 3.5p7 says:
> 
>   "When a block scope declaration of an entity with linkage is not
>    found to refer to some other declaration, then that entity is a
>    member of the innermost enclosing namespace. However such a
(Continue reading)

Enea Zaffanella | 4 Aug 08:18 2012
Picon

Re: The DeclContext of block-scope function declarations.

On 08/01/2012 07:09 PM, Douglas Gregor wrote:
 >
 > On Jul 9, 2012, at 1:57 AM, Enea Zaffanella <zaffanella@...> 
wrote:
 >
 >> Consider the following program:
 >>
 >> $ cat block.cc
 >> namespace N {
 >>
 >> void f() {
 >>    extern int var;     // #1
 >>    extern void g(int); // #2
 >>    g(var);
 >> }
 >>
 >> class S {
 >>    friend void h();    // #3
 >> };
 >>
 >> } // namespace N
 >>

[...]

 > This is a longstanding [*] problem in Clang's representation. The
lexical DeclContext should be the function for #1 and #2, while the
semantic DeclContext should be the nearest enclosing namespace. Ideally,
name lookup for redeclarations (but not uses) would then be able to find
these functions, so that in
(Continue reading)

Douglas Gregor | 6 Aug 17:21 2012
Picon

Re: The DeclContext of block-scope function declarations.


On Aug 3, 2012, at 11:18 PM, Enea Zaffanella <zaffanella@...> wrote:

> On 08/01/2012 07:09 PM, Douglas Gregor wrote:
> >
> > On Jul 9, 2012, at 1:57 AM, Enea Zaffanella <zaffanella@...> wrote:
> >
> >> Consider the following program:
> >>
> >> $ cat block.cc
> >> namespace N {
> >>
> >> void f() {
> >>    extern int var;     // #1
> >>    extern void g(int); // #2
> >>    g(var);
> >> }
> >>
> >> class S {
> >>    friend void h();    // #3
> >> };
> >>
> >> } // namespace N
> >>
> 
> [...]
> 
> > This is a longstanding [*] problem in Clang's representation. The
> lexical DeclContext should be the function for #1 and #2, while the
> semantic DeclContext should be the nearest enclosing namespace. Ideally,
(Continue reading)


Gmane