[cfe-dev] PATCH: Cleanup function redeclaration representations

Doug Gregor doug.gregor at gmail.com
Thu Apr 24 06:29:22 PDT 2008


On Thu, Apr 24, 2008 at 9:12 AM, Neil Booth <neil at daikokuya.co.uk> wrote:
> Don't forget that redeclarations needn't be at global scope, and the
>  composite type only applies where the redeclaration is visible; as
>  soon as it goes out of scope the type of the visible declaration is
>  the semantic type.

In C++, it isn't a redeclaration if it's not in the same scope
([over.dcl]p1 says as such). One can have multiple declarations at
different scopes that end up referring to the same function, e.g.,

  extern "C" void foo(int);

could occur in several local scopes. However, this doesn't meet the
C++ definition of a redeclaration. Perhaps C is different?

Clang currently considers declarations from different scopes to be
completely different entities. A function declared in a local scope
will be popped off the stack once Clang leaves that local scope, so it
"does the right thing" with these.

  - Doug



More information about the cfe-dev mailing list