13377 – [3.4 regression] unexpected behavior of namespace usage directive (original) (raw)

Description Boris Kolpackov 2003-12-10 17🔞33 UTC

$ cat > test.cpp namespace N1 { namespace N2 { } }

namespace N2 { }

using namespace N1; using namespace N2;

$ g++ --version g++ (GCC) 3.3.2 (Debian) $ g++ -c test.cpp test.cpp:13: error: `' is not a namespace $

Comment 1 Drea Pinski 2003-12-10 17:44:06 UTC

Related to bug 12272. Confirmed. The error message on the mainline: pr13377.cc:13: error: expected namespace-name pr13377.cc:13: error: `' is not a namespace

Comment 2 Volker Reichelt 2005-08-29 13:32:50 UTC

Testing a patch.

Comment 5 Volker Reichelt 2005-08-31 11:07:38 UTC

For the testcase

================================== namespace N { int i; }

int i;

using namespace N;

void foo() { i; }

we now get

ambig4.C: In function 'void foo()': ambig4.C:10: error: use of 'i' is ambiguous ambig4.C:6: error: first declared as 'int i' here ambig4.C:3: error: also declared as 'int N::i' here ambig4.C:10: error: 'i' was not declared in this scope

Btw, this is the testcase which was a regression from GCC 3.3.x.

For the testcase

================================== namespace N { namespace M {} }

namespace M {}

using namespace N; using namespace M;

we now get (since the patch for PR23586 is also in place):

ambig5.C:13: error: use of 'M' is ambiguous ambig5.C:10: error: first declared as 'namespace M { }' here ambig5.C:7: error: also declared as 'namespace M { }' here ambig5.C:13: error: 'M' is not a namespace-name ambig5.C:13: error: expected namespace-name before ';' token

This is still a little suboptimal (first we say it's ambiguous, then we say it's not declared/not a namespace-name), but I think the user can figure out the problem now.

So this is fixed on mainline and the 4.0 branch.

Comment 7 Volker Reichelt 2005-09-01 11:33:50 UTC

Fixed on the 3.4 branch, too.