[cfe-dev] Attempt at CXX Namespaces

Eli Friedman eli.friedman at gmail.com
Mon Feb 25 13:46:12 PST 2008


On Mon, Feb 25, 2008 at 11:32 AM, Kevin Tew <tewk at cs.utah.edu> wrote:
> I've gotten serious and have written some code.
>
>  Following the clang web page's advice, I've tried to start implementing
>  c++ namespaces.
>  Currently, I'm trying to figure out how to add namespace members to my
>  NamespaceDecl.

Hmm, not a bad start.  A couple of comments from reading your patch.
First, make sure you don't go over 80 characters per line.  Second, I
don't think that making NamespaceDecl a subclass of RecordDecl really
makes sense: a namespace doesn't have members in the same sense that a
class or struct does.  Maybe make it a direct subclass of ScopedDecl?
Also, a few more tests might be appropriate.

Doesn't necessarily need to be done in this patch, but it would be
nice if the places that print out namespaced identifiers (like dump()
and related) would print out the associated namespace, so that things
don't get so confusing.

Also, here's a testcase which I'm not sure your patch handles:
namespace a { double i; }
int i;
namespace a {double* j = &i;}
should not print a warning with -pedantic.

I can't really come up with any other tests that have to do with
namespaces in particular... namespaces are pretty simple without
"using" and the :: operator.

-Eli



More information about the cfe-dev mailing list