For an invalid code snippet like int i; namespace N = i; we issue the error message bug.cc:2: error: expected namespace-name before ';' token bug.cc:2: error: unknown namespace '<declaration error>' with the not very helpful '<declaration error>'. The situation for the code snippet int i; using namespace i; is similar. Here we get the error message: bug.cc:2: error: expected namespace-name before ';' token bug.cc:2: error: '<type error>' is not a namespace With the old parser we got bug.cc:2: error: unknown namespace `i' resp. bug.cc:2: error: namespace `i' undeclared so this qualifies as a diagnostic regression. I'll post a patch soon.
Confirmed.
Btw, the problem is related to PR13377. The problem there is twofold: The compiler fails to report which name is not a namespace-name (N2) and why (because it's ambiguous). The patch would only fix the first problem; the second would still remain.
Subject: Bug 23586 CVSROOT: /cvs/gcc Module name: gcc Changes by: reichelt@gcc.gnu.org 2005-08-30 16:22:01 Modified files: gcc/cp : ChangeLog parser.c name-lookup.c Log message: PR c++/23586 * parser.c (cp_parser_namespace_name): Move diagnostic for invalid namespace-name to here from ... * name-lookup.c (do_namespace_alias): ... here and ... (do_using_directive): ... here. Remove dead code. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4862&r2=1.4863 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.351&r2=1.352 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&r1=1.138&r2=1.139
Subject: Bug 23586 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: reichelt@gcc.gnu.org 2005-08-30 16:25:54 Modified files: gcc/cp : ChangeLog parser.c name-lookup.c Log message: PR c++/23586 * parser.c (cp_parser_namespace_name): Move diagnostic for invalid namespace-name to here from ... * name-lookup.c (do_namespace_alias): ... here and ... (do_using_directive): ... here. Remove dead code. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.85&r2=1.4648.2.86 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.319.2.12&r2=1.319.2.13 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.109.4.7&r2=1.109.4.8
Fixed on the 4.0 branch (for 4.0.2) and mainline. Testing patch for the 3.4 branch.
Patch for the 3.4 branch posted.
Subject: Bug 23586 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: reichelt@gcc.gnu.org 2005-08-31 10:16:05 Modified files: gcc/cp : ChangeLog parser.c name-lookup.c Log message: PR c++/23586 * parser.c (cp_parser_namespace_name): Move diagnostic for invalid namespace-name to here from ... * name-lookup.c (do_namespace_alias): ... here and ... (do_using_directive): ... here. Remove dead code. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.230&r2=1.3892.2.231 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.58&r2=1.157.2.59 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.34.2.22&r2=1.34.2.23
Now also fixed on the 3.4 branch.