]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
2003-05-07 David Carlton <carlton@bactrian.org>
authorDavid Carlton <carlton@bactrian.org>
Thu, 8 May 2003 01:10:52 +0000 (01:10 +0000)
committerDavid Carlton <carlton@bactrian.org>
Thu, 8 May 2003 01:10:52 +0000 (01:10 +0000)
* 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.

gdb/ChangeLog
gdb/c-exp.y
gdb/eval.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.c++/namespace.exp
gdb/valops.c
gdb/value.h

index 20cbf088309d4dedb4a88027cdbf32266a4629a6..c06000fef3dca6958db68b500cbc5c44ceb647b5 100644 (file)
@@ -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
index dae4aca80755e5d84e63a28acb1b70b7a349d8f8..2933e32e0634552fb1a8c9c5984543d38f112c2e 100644 (file)
@@ -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;
index 17dd0964fc5da31b7d5e4ef5c4882f83945043f1..56c2206ed9990ae02e9656e2e3e8d77076a64755 100644 (file)
@@ -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;
index a6e09e21ee23c1de4a52eac8228a3cc595261c11..376952c0a38eb95373272fdff113544e4a55c51a 100644 (file)
@@ -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.
index 57b7f32050284c916e69aec429e4b3b598d9cf95..b0ef10414b851a7867d20f09744a15ee3905302d 100644 (file)
@@ -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.
 
index 9706111b9457ab351af889961700240104577a74..b555bb16e16d4e10d22c911c66c45738c902c630 100644 (file)
@@ -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
index 0023f63e2b2a72292cfd95e134f24c4cf980a7b8..34e80e3364db7bded7255f5f2e212922bebdbd66 100644 (file)
@@ -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);