Bug 8693 - names of c++ nested types in casts must be enclosed in quotes
Summary: names of c++ nested types in casts must be enclosed in quotes
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.1
: P3 normal
Target Milestone: 7.2
Assignee: Tom Tromey
URL:
Keywords:
: 8922 9175 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-03-17 20:08 UTC by David Carlton
Modified: 2010-02-19 20:23 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Carlton 2004-03-17 20:08:00 UTC
[Converted from Gnats 1588]

Say we have a type Inner contained in a class or
namespace Outer.  Then, if you print an expression
that refers to Outer::Inner in a situation where
the parser needs to know that Outer::Inner is a type
(as opposed to some other sort of variable) to
disambiguate the parse, you must enclose the name of
the type in single quotes.

This mainly shows up in casts: if you type

(gdb) p (Outer::Inner) foo

then GDB will think that the parentheses are used
for grouping instead of for a cast, unless you
use single quotes; similarly, if you type

(gdb) p (Outer::Inner *) foo

then GDB will think that the * is used for multiplication
instead of as a pointer.  (By the time it hits the
right parenthesis, it's too late.)

This issue is new to GDB 6.1; however, before GDB 6.1,
GDB would very rarely get the name of the type right
in the first place, thinking it was called "Inner"
instead of "Outer::Inner", so the issue didn't arise
very frequently.  (The only situations that I know
of where it did arise were when using GCC 3.3 or later
with -gstabs+ in a context where Outer was a class
(as opposed to a namespace) and perhaps some situations
involving HP's aCC.)

Release:
2004-03-17-cvs (or gdb 6.1)

Environment:
any
Comment 1 David Carlton 2004-03-17 20:11:22 UTC
From: carlton@sources.redhat.com
To: gdb-gnats@sourceware.org
Cc:  
Subject: c++/1588
Date: 17 Mar 2004 20:11:22 -0000

 CVSROOT:	/cvs/src
 Module name:	src
 Changes by:	carlton@sourceware.org	2004-03-17 20:11:22
 
 Modified files:
 	gdb/testsuite  : ChangeLog 
 	gdb/testsuite/gdb.cp: classes.exp 
 
 Log message:
 	2004-03-17  David Carlton  <carlton@kealia.com>
 	
 	* gdb.cp/classes.exp (test_enums): Refer to PR c++/1588 instead of
 	PR c++/826.
 
 Patches:
 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.831&r2=1.832
 http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/classes.exp.diff?cvsroot=src&r1=1.9&r2=1.10
Comment 2 Tom Tromey 2010-01-22 21:09:06 UTC
*** Bug 8922 has been marked as a duplicate of this bug. ***
Comment 3 Sourceware Commits 2010-02-19 20:22:17 UTC
Subject: Bug 8693

CVSROOT:	/cvs/src
Module name:	src
Changes by:	tromey@sourceware.org	2010-02-19 20:22:03

Modified files:
	gdb            : ChangeLog c-exp.y cp-namespace.c 
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.cp: namespace.exp 

Log message:
	gdb
	PR c++/8693, PR c++/9496:
	* cp-namespace.c (cp_lookup_nested_type): Handle TYPE_CODE_UNION.
	* c-exp.y (lex_one_token): Rename from yylex.  Don't call
	write_dollar_variable.  Don't try to classify NAME tokens.
	(token_and_value): New type.
	(token_fifo, popping, name_obstack): New globals.
	(classify_name): New function.
	(classify_inner_name): Likewise.
	(yylex): Likewise.
	(VARIABLE): Now has type sval.
	(exp : VARIABLE): Call write_dollar_variable.
	(qualified_name): Use TYPENAME, not typebase.  Add production for
	multiple "::" instances.
	(variable): Use name_not_typename.
	(qualified_type): Remove.
	(typebase): Update.
	gdb/testsuite
	PR c++/8693, PR c++/9496:
	* gdb.cp/namespace.exp: Remove some setup_kfail calls.  Added
	regression tests.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11381&r2=1.11382
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/c-exp.y.diff?cvsroot=src&r1=1.70&r2=1.71
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/cp-namespace.c.diff?cvsroot=src&r1=1.34&r2=1.35
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2149&r2=1.2150
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/namespace.exp.diff?cvsroot=src&r1=1.16&r2=1.17

Comment 4 Tom Tromey 2010-02-19 20:23:53 UTC
I checked in the fix.