*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / ada-exp.y
index e44cc683bcc05b3209684f162f884fd7347c05cb..722db2fc079619cd29ae7ed0b6ef98036d5d2df8 100644 (file)
@@ -1,23 +1,21 @@
 /* YACC parser for Ada expressions, for GDB.
    Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994, 1997, 2000, 2003, 2004,
-   2007, 2008 Free Software Foundation, Inc.
+   2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
-This file is part of GDB.
+   This file is part of GDB.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* Parse an Ada expression from text in a string,
    and return the result as a  struct expression  pointer.
@@ -52,6 +50,8 @@ Boston, MA 02110-1301, USA.  */
 #include "frame.h"
 #include "block.h"
 
+#define parse_type builtin_type (parse_gdbarch)
+
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
    as well as gratuitiously global symbol names, so we can have multiple
    yacc generated parsers in gdb.  These are only the variables
@@ -571,7 +571,7 @@ opt_type_prefix :
                type_prefix
        |       /* EMPTY */
                        { write_exp_elt_opcode (OP_TYPE);
-                         write_exp_elt_type (builtin_type_void);
+                         write_exp_elt_type (parse_type->builtin_void);
                          write_exp_elt_opcode (OP_TYPE); }
        ;
 
@@ -985,7 +985,7 @@ write_object_renaming (struct block *orig_left_context,
          if (end == NULL)
            end = renaming_expr + strlen (renaming_expr);
          field_name.length = end - renaming_expr;
-         field_name.ptr = xmalloc (end - renaming_expr + 1);
+         field_name.ptr = malloc (end - renaming_expr + 1);
          strncpy (field_name.ptr, renaming_expr, end - renaming_expr);
          field_name.ptr[end - renaming_expr] = '\000';
          renaming_expr = end;
@@ -1021,8 +1021,8 @@ block_lookup (struct block *context, char *raw_name)
     name = ada_encode (raw_name);
 
   nsyms = ada_lookup_symbol_list (name, context, VAR_DOMAIN, &syms);
-  if (context == NULL &&
-      (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK))
+  if (context == NULL
+      && (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK))
     symtab = lookup_symtab (name);
   else
     symtab = NULL;
@@ -1081,8 +1081,8 @@ static struct type*
 find_primitive_type (char *name)
 {
   struct type *type;
-  type = language_lookup_primitive_type_by_name (current_language,
-                                                current_gdbarch,
+  type = language_lookup_primitive_type_by_name (parse_language,
+                                                parse_gdbarch,
                                                 name);
   if (type == NULL && strcmp ("system__address", name) == 0)
     type = type_system_address ();
@@ -1091,7 +1091,6 @@ find_primitive_type (char *name)
     {
       /* Check to see if we have a regular definition of this
         type that just didn't happen to have been read yet.  */
-      int ntypes;
       struct symbol *sym;
       char *expanded_name = 
        (char *) alloca (strlen (name) + sizeof ("standard__"));
@@ -1207,6 +1206,7 @@ get_symbol_field_type (struct symbol *sym, char *encoded_field_name)
 
   if (type == NULL || field_name == NULL)
     return NULL;
+  type = check_typedef (type);
 
   while (field_name[0] != '\0')
     {
@@ -1365,7 +1365,6 @@ write_var_or_type (struct block *block, struct stoken name0)
            }
          else if (nsyms == 0) 
            {
-             int i;
              struct minimal_symbol *msym 
                = ada_lookup_simple_minsym (encoded_name);
              if (msym != NULL)
@@ -1451,7 +1450,7 @@ convert_char_literal (struct type *type, LONGEST val)
 
   if (type == NULL || TYPE_CODE (type) != TYPE_CODE_ENUM)
     return val;
-  sprintf (name, "QU%02x", (int) val);
+  xsnprintf (name, sizeof (name), "QU%02x", (int) val);
   for (f = 0; f < TYPE_NFIELDS (type); f += 1)
     {
       if (strcmp (name, TYPE_FIELD_NAME (type, f)) == 0)
@@ -1463,61 +1462,64 @@ convert_char_literal (struct type *type, LONGEST val)
 static struct type *
 type_int (void)
 {
-  return builtin_type_int;
+  return parse_type->builtin_int;
 }
 
 static struct type *
 type_long (void)
 {
-  return builtin_type_long;
+  return parse_type->builtin_long;
 }
 
 static struct type *
 type_long_long (void)
 {
-  return builtin_type_long_long;
+  return parse_type->builtin_long_long;
 }
 
 static struct type *
 type_float (void)
 {
-  return builtin_type_float;
+  return parse_type->builtin_float;
 }
 
 static struct type *
 type_double (void)
 {
-  return builtin_type_double;
+  return parse_type->builtin_double;
 }
 
 static struct type *
 type_long_double (void)
 {
-  return builtin_type_long_double;
+  return parse_type->builtin_long_double;
 }
 
 static struct type *
 type_char (void)
 {
-  return language_string_char_type (current_language, current_gdbarch);
+  return language_string_char_type (parse_language, parse_gdbarch);
 }
 
 static struct type *
 type_boolean (void)
 {
-  return builtin_type_bool;
+  return parse_type->builtin_bool;
 }
 
 static struct type *
 type_system_address (void)
 {
   struct type *type 
-    = language_lookup_primitive_type_by_name (current_language,
-                                             current_gdbarch, 
+    = language_lookup_primitive_type_by_name (parse_language,
+                                             parse_gdbarch,
                                              "system__address");
-  return  type != NULL ? type : lookup_pointer_type (builtin_type_void);
+  return  type != NULL ? type : parse_type->builtin_data_ptr;
 }
 
+/* Provide a prototype to silence -Wmissing-prototypes.  */
+extern initialize_file_ftype _initialize_ada_exp;
+
 void
 _initialize_ada_exp (void)
 {
This page took 0.035122 seconds and 4 git commands to generate.