aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Carlton <carlton@bactrian.org>2003-05-08 01:10:52 +0000
committerDavid Carlton <carlton@bactrian.org>2003-05-08 01:10:52 +0000
commit5eee26615579f8d4e9d4f88130684dd5d8f25c65 (patch)
treec5980f0db749945b892ee016bbd644e9fd449eec
parentfcc3ea19593cfcbcdd5f4a241fb206f0fe7edd48 (diff)
downloadgdb-5eee26615579f8d4e9d4f88130684dd5d8f25c65.zip
gdb-5eee26615579f8d4e9d4f88130684dd5d8f25c65.tar.gz
gdb-5eee26615579f8d4e9d4f88130684dd5d8f25c65.tar.bz2
2003-05-07 David Carlton <carlton@bactrian.org>
* valops.c (value_aggregate_elt): Add 'noside' argument. (value_struct_elt_for_reference): Add 'block', 'noside' arguments. Call value_maybe_namespace_elt. (value_namespace_elt): Add 'noside' argument. Break out code into value_maybe_namespace_elt. (value_maybe_namespace_elt): New. Handle types. * value.h: Update declaration for value_aggregate_elt. * eval.c (evaluate_subexp_standard): Pass 'noside' to value_aggregate_elt. * c-exp.y: Added 'qualified_type'. (yylex): Comment out nested type stuff. 2003-05-07 David Carlton <carlton@bactrian.org> * gdb.c++/namespace.exp: Update messages to match new parser changes.
-rw-r--r--gdb/ChangeLog14
-rw-r--r--gdb/c-exp.y30
-rw-r--r--gdb/eval.c3
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.c++/namespace.exp4
-rw-r--r--gdb/valops.c69
-rw-r--r--gdb/value.h3
7 files changed, 107 insertions, 21 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 20cbf08..c06000f 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,17 @@
+2003-05-07 David Carlton <carlton@bactrian.org>
+
+ * valops.c (value_aggregate_elt): Add 'noside' argument.
+ (value_struct_elt_for_reference): Add 'block', 'noside'
+ arguments. Call value_maybe_namespace_elt.
+ (value_namespace_elt): Add 'noside' argument. Break out code into
+ value_maybe_namespace_elt.
+ (value_maybe_namespace_elt): New. Handle types.
+ * value.h: Update declaration for value_aggregate_elt.
+ * eval.c (evaluate_subexp_standard): Pass 'noside' to
+ value_aggregate_elt.
+ * c-exp.y: Added 'qualified_type'.
+ (yylex): Comment out nested type stuff.
+
2003-05-02 David Carlton <carlton@bactrian.org>
* minsyms.c: Delete declarations for lookup_minimal_symbol_linkage
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index dae4aca..2933e32 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -153,7 +153,7 @@ static int parse_number (char *, int, int, YYSTYPE *);
%type <voidval> exp exp1 type_exp start variable qualified_name lcurly
%type <lval> rcurly
-%type <tval> type typebase
+%type <tval> type typebase qualified_type
%type <tvec> nonempty_typelist
/* %type <bval> block */
@@ -898,6 +898,32 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */
{ $$ = follow_types ($2); }
| typebase const_or_volatile_or_space_identifier_noopt
{ $$ = follow_types ($1); }
+ | qualified_type
+ ;
+
+qualified_type: typebase COLONCOLON name
+ {
+ struct type *type = $1;
+ struct type *new_type;
+ char *ncopy = alloca ($3.length + 1);
+
+ memcpy (ncopy, $3.ptr, $3.length);
+ ncopy[$3.length] = '\0';
+
+ if (TYPE_CODE (type) != TYPE_CODE_STRUCT
+ && TYPE_CODE (type) != TYPE_CODE_UNION
+ && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
+ error ("`%s' is not defined as an aggregate type.",
+ TYPE_NAME (type));
+
+ new_type = lookup_nested_type (type, ncopy,
+ expression_context_block);
+ if (new_type == NULL)
+ error ("No type \"%s\" within class or namespace \"%s\".",
+ ncopy, TYPE_NAME (type));
+
+ $$ = new_type;
+ }
;
typename: TYPENAME
@@ -1704,7 +1730,7 @@ yylex ()
if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
{
-#if 1
+#if 0
char *p;
char *namestart;
struct type *best_type;
diff --git a/gdb/eval.c b/gdb/eval.c
index 17dd096..56c2206 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -409,7 +409,8 @@ evaluate_subexp_standard (struct type *expect_type,
(*pos) += 5 + BYTES_TO_EXP_ELEM (tem + 1);
arg1 = value_aggregate_elt (exp->elts[pc + 1].type,
exp->elts[pc + 2].block,
- &exp->elts[pc + 4].string);
+ &exp->elts[pc + 4].string,
+ noside);
if (arg1 == NULL)
error ("There is no field named %s", &exp->elts[pc + 4].string);
return arg1;
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a6e09e2..376952c 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2003-05-07 David Carlton <carlton@bactrian.org>
+
+ * gdb.c++/namespace.exp: Update messages to match new parser
+ changes.
+
2003-05-02 David Carlton <carlton@bactrian.org>
* gdb.c++/rtti.h: New.
diff --git a/gdb/testsuite/gdb.c++/namespace.exp b/gdb/testsuite/gdb.c++/namespace.exp
index 57b7f32..b0ef104 100644
--- a/gdb/testsuite/gdb.c++/namespace.exp
+++ b/gdb/testsuite/gdb.c++/namespace.exp
@@ -255,14 +255,14 @@ gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n public:\r\n int
gdb_test "ptype ::C::CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n public:\r\n int y;\r\n\}"
gdb_test "ptype ::C::NestedClass" "No symbol \"NestedClass\" in namespace \"C\"."
gdb_test "ptype C::CClass" "No symbol \"CClass\" in namespace \"C::C\"."
-gdb_test "ptype C::CClass::NestedClass" "No symbol \"CClass\" in namespace \"C::C\"."
+gdb_test "ptype C::CClass::NestedClass" "No type \"CClass\" within class or namespace \"C::C\"."
gdb_test "ptype C::NestedClass" "No symbol \"NestedClass\" in namespace \"C::C\"."
# Tests involving multiple files
gdb_test "ptype OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n\}"
gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n\}"
-gdb_test "ptype C::OtherFileClass" "No symbol \"Class\" in namespace \"C::C\"."
+gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"."
# Some anonymous namespace tests.
diff --git a/gdb/valops.c b/gdb/valops.c
index 9706111..b555bb1 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -101,11 +101,20 @@ static struct value *value_struct_elt_for_reference (struct type *domain,
int offset,
struct type *curtype,
const char *name,
- struct type *intype);
+ struct type *intype,
+ const struct block *
+ block,
+ enum noside noside);
static struct value *value_namespace_elt (const struct type *curtype,
const struct block *block,
- const char *name);
+ const char *name,
+ enum noside noside);
+
+static struct value *value_maybe_namespace_elt (const struct type *curtype,
+ const struct block *block,
+ const char *name,
+ enum noside noside);
static CORE_ADDR allocate_space_in_inferior (int);
@@ -2507,15 +2516,17 @@ check_field (struct value *arg1, const char *name)
struct value *
value_aggregate_elt (struct type *curtype,
const struct block *block,
- const char *name)
+ const char *name,
+ enum noside noside)
{
switch (TYPE_CODE (curtype))
{
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
- return value_struct_elt_for_reference (curtype, 0, curtype, name, NULL);
+ return value_struct_elt_for_reference (curtype, 0, curtype, name, NULL,
+ block, noside);
case TYPE_CODE_NAMESPACE:
- return value_namespace_elt (curtype, block, name);
+ return value_namespace_elt (curtype, block, name, noside);
default:
error ("Internal error: non-aggregate type to value_aggregate_elt");
}
@@ -2531,7 +2542,9 @@ value_aggregate_elt (struct type *curtype,
static struct value *
value_struct_elt_for_reference (struct type *domain, int offset,
struct type *curtype, const char *name,
- struct type *intype)
+ struct type *intype,
+ const struct block *block,
+ enum noside noside)
{
register struct type *t = curtype;
register int i;
@@ -2650,11 +2663,17 @@ value_struct_elt_for_reference (struct type *domain, int offset,
offset + base_offset,
TYPE_BASECLASS (t, i),
name,
- intype);
+ intype,
+ block,
+ noside);
if (v)
return v;
}
- return 0;
+
+ /* As a last chance, look it up using lookup_symbol_namespace: this
+ works for types. */
+
+ return value_maybe_namespace_elt (curtype, block, name, noside);
}
/* C++: Return the member NAME of the namespace given by the type
@@ -2664,7 +2683,27 @@ value_struct_elt_for_reference (struct type *domain, int offset,
static struct value *
value_namespace_elt (const struct type *curtype,
const struct block *block,
- const char *name)
+ const char *name,
+ enum noside noside)
+{
+ struct value *retval = value_maybe_namespace_elt (curtype, block, name,
+ noside);
+
+ if (retval == NULL)
+ error ("No symbol \"%s\" in namespace \"%s\".", name,
+ TYPE_TAG_NAME (curtype));
+
+ return retval;
+}
+
+/* A helper function used by value_namespace_elt and
+ value_struct_elt_for_reference. */
+
+static struct value *
+value_maybe_namespace_elt (const struct type *curtype,
+ const struct block *block,
+ const char *name,
+ enum noside noside)
{
const char *namespace_name = TYPE_TAG_NAME (curtype);
const struct symbol *sym;
@@ -2672,13 +2711,13 @@ value_namespace_elt (const struct type *curtype,
sym = lookup_symbol_namespace (namespace_name, name, NULL,
block, VAR_NAMESPACE, NULL);
- /* FIXME: carlton/2002-11-24: Should this really be here, or should
- it be in c-exp.y like the other similar messages? Hmm... */
-
if (sym == NULL)
- error ("No symbol \"%s\" in namespace \"%s\".", name, namespace_name);
-
- return value_of_variable (sym, block);
+ return NULL;
+ else if ((noside == EVAL_AVOID_SIDE_EFFECTS)
+ && (SYMBOL_CLASS (sym) == LOC_TYPEDEF))
+ return allocate_value (SYMBOL_TYPE (sym));
+ else
+ return value_of_variable (sym, block);
}
/* Given a pointer value V, find the real (RTTI) type
diff --git a/gdb/value.h b/gdb/value.h
index 0023f63..34e80e3 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -375,7 +375,8 @@ extern struct value *value_struct_elt (struct value **argp,
extern struct value *value_aggregate_elt (struct type *curtype,
const struct block *block,
- const char *name);
+ const char *name,
+ enum noside noside);
extern struct value *value_static_field (struct type *type, int fieldno);