aboutsummaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
authorDavid Carlton <carlton@bactrian.org>2003-09-25 16:39:39 +0000
committerDavid Carlton <carlton@bactrian.org>2003-09-25 16:39:39 +0000
commit79c2c32df4d14566f2d11310fddd4e4ca9ab6542 (patch)
treea5e0893e16910a2814ae39a59ab3293a7d86ecbb /gdb/valops.c
parent594e6d67cd35735bd5eb9eca720560a8336eac37 (diff)
downloadgdb-79c2c32df4d14566f2d11310fddd4e4ca9ab6542.zip
gdb-79c2c32df4d14566f2d11310fddd4e4ca9ab6542.tar.gz
gdb-79c2c32df4d14566f2d11310fddd4e4ca9ab6542.tar.bz2
2003-09-25 David Carlton <carlton@kealia.com>
* c-exp.y: Include cp-support.h. Add qualified_type. (yylex): Delete nested type hack; add comments. * cp-namespace.c (cp_lookup_nested_type): New function. * cp-support.h: Declare cp_lookup_nested_type. * eval.c (evaluate_subexp_standard): Call value_aggregate_elt instead of value_struct_elt_for_reference. * valops.c: Include cp-support.h. (value_aggregate_elt): New function. (value_namespace_elt): Ditto. (value_struct_elt_for_reference): Make static. * value.h: Delete declaration of value_struct_elt_for_reference; add declaration for value_aggregate_elt. * Makefile.in (c-exp.tab.o): Depend on $(cp_support_h). (valops.o): Ditto. 2003-09-25 David Carlton <carlton@kealia.com> * gdb.cp/namespace.exp: Tweak comments. Add non-quoted versions of some print tests, where appropriate. Add tests for C::D::cd, E::ce, F::cXfX, G::XgX. * gdb.cp/namespace.cc: Add XgX, cXfX, ce.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index 8deb473..08036de 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -41,6 +41,7 @@
#include <errno.h>
#include "gdb_string.h"
#include "gdb_assert.h"
+#include "cp-support.h"
/* Flag indicating HP compilers were used; needed to correctly handle some
value operations with HP aCC code/runtime. */
@@ -63,6 +64,17 @@ static struct value *search_struct_method (char *, struct value **,
static int check_field_in (struct type *, const char *);
+
+static struct value *value_struct_elt_for_reference (struct type *domain,
+ int offset,
+ struct type *curtype,
+ char *name,
+ struct type *intype);
+
+static struct value *value_namespace_elt (const struct type *curtype,
+ const char *name,
+ enum noside noside);
+
static CORE_ADDR allocate_space_in_inferior (int);
static struct value *cast_into_complex (struct type *, struct value *);
@@ -2208,6 +2220,30 @@ check_field (struct value *arg1, const char *name)
}
/* C++: Given an aggregate type CURTYPE, and a member name NAME,
+ return the appropriate member. This function is used to resolve
+ user expressions of the form "DOMAIN::NAME". For more details on
+ what happens, see the comment before
+ value_struct_elt_for_reference. */
+
+struct value *
+value_aggregate_elt (struct type *curtype,
+ 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);
+ case TYPE_CODE_NAMESPACE:
+ return value_namespace_elt (curtype, name, noside);
+ default:
+ internal_error (__FILE__, __LINE__,
+ "non-aggregate type in value_aggregate_elt");
+ }
+}
+
+/* C++: Given an aggregate type CURTYPE, and a member name NAME,
return the address of this member as a "pointer to member"
type. If INTYPE is non-null, then it will be the type
of the member we are looking for. This will help us resolve
@@ -2347,6 +2383,37 @@ value_struct_elt_for_reference (struct type *domain, int offset,
return 0;
}
+/* C++: Return the member NAME of the namespace given by the type
+ CURTYPE. */
+
+static struct value *
+value_namespace_elt (const struct type *curtype,
+ const char *name,
+ enum noside noside)
+{
+ const char *namespace_name = TYPE_TAG_NAME (curtype);
+ struct symbol *sym;
+ struct value *retval;
+
+ sym = cp_lookup_symbol_namespace (namespace_name, name, NULL,
+ get_selected_block (0), VAR_DOMAIN,
+ NULL);
+
+ if (sym == NULL)
+ retval = NULL;
+ else if ((noside == EVAL_AVOID_SIDE_EFFECTS)
+ && (SYMBOL_CLASS (sym) == LOC_TYPEDEF))
+ retval = allocate_value (SYMBOL_TYPE (sym));
+ else
+ retval = value_of_variable (sym, get_selected_block (0));
+
+ if (retval == NULL)
+ error ("No symbol \"%s\" in namespace \"%s\".", name,
+ TYPE_TAG_NAME (curtype));
+
+ return retval;
+}
+
/* Given a pointer value V, find the real (RTTI) type
of the object it points to.