Bug 23586 - [3.4 regression] Bad diagnostic for invalid namespace-name
Summary: [3.4 regression] Bad diagnostic for invalid namespace-name
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.0
: P2 minor
Target Milestone: 3.4.5
Assignee: Volker Reichelt
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: diagnostic, patch
Depends on:
Blocks: 13377
  Show dependency treegraph
 
Reported: 2005-08-26 22:17 UTC by Volker Reichelt
Modified: 2005-08-31 10:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-08-26 22:20:02


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Reichelt 2005-08-26 22:17:50 UTC
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.
Comment 1 Andrew Pinski 2005-08-26 22:20:02 UTC
Confirmed.
Comment 2 Volker Reichelt 2005-08-26 22:21:18 UTC
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.
Comment 3 CVS Commits 2005-08-30 16:22:36 UTC
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

Comment 4 CVS Commits 2005-08-30 16:26:10 UTC
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

Comment 5 Volker Reichelt 2005-08-30 16:28:19 UTC
Fixed on the 4.0 branch (for 4.0.2) and mainline.

Testing patch for the 3.4 branch.
Comment 6 Volker Reichelt 2005-08-31 08:32:09 UTC
Patch for the 3.4 branch posted.
Comment 7 CVS Commits 2005-08-31 10:16:23 UTC
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

Comment 8 Volker Reichelt 2005-08-31 10:17:27 UTC
Now also fixed on the 3.4 branch.