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]

CVS head (gcc-3.4), new parser, and should variable names interfere with namespace names?


Hi All,

 With the recent parser changes, the following snippet of code now
doesn't compile...

namespace.cxx:
-----------------------
namespace foo {
    int baz(int);
}

int
bar(int foo)
{
    return (foo::baz(foo));
}
------------------------

% g++34 namespace.cxx
namespace.cxx: In function `int bar(int)':
namespace.cxx:8: error: `foo' is not a class-name or namespace-name
namespace.cxx:8: error: `foo' is not a class-name or namespace-name
namespace.cxx:8: error: `foo' is not a class-name or namespace-name
namespace.cxx:8: error: `foo' is not a class-name or namespace-name
namespace.cxx:8: error: `baz' undeclared (first use this function)
namespace.cxx:8: error: (Each undeclared identifier is reported only once for
   each function it appears in.)

Whereas gcc-3.3.x and earlier do compile it.

Is the parser just being more standard conforming, or should it be
able to work out what is meant here? ie should the definition of 'int
foo' be hiding the 'namespace foo'?

Fully qualifing the namespace makes it work again... ie

    return (::foo::baz(foo));

Andrew.
--
 Andrew Pollard, Brooks-PRI Automation  | home: andrew@andypo.net
670 Eskdale Road, Winnersh Triangle, UK | work: Andrew.Pollard@brooks-pri.com
 Tel/Fax:+44 (0)118 9215603 / 9215660   | http://www.andypo.net


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