* sunos.c (sunos_add_one_symbol): Treat a common symbol from a
[deliverable/binutils-gdb.git] / gdb / c-exp.y
index 6a96eb11ee42266dbe64bafd88b44edaf8f43292..399b2aaa4a020c72e21cb2a720cf103243cc14e5 100644 (file)
@@ -1,5 +1,6 @@
 /* YACC parser for C expressions, for GDB.
-   Copyright (C) 1986, 1989, 1990, 1991 Free Software Foundation, Inc.
+   Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994
+   Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -37,6 +38,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 %{
 
 #include "defs.h"
+#include <string.h>
 #include "expression.h"
 #include "value.h"
 #include "parser-defs.h"
@@ -903,6 +905,7 @@ parse_number (p, len, parsed_float, putithere)
      here, and we do kind of silly things like cast to unsigned.  */
   register LONGEST n = 0;
   register LONGEST prevn = 0;
+  unsigned LONGEST un;
 
   register int i = 0;
   register int c;
@@ -1023,8 +1026,9 @@ parse_number (p, len, parsed_float, putithere)
      the case where it is we just always shift the value more than
      once, with fewer bits each time.  */
 
+  un = (unsigned LONGEST)n >> 2;
   if (long_p == 0
-      && (((unsigned LONGEST)n >> 2) >> (TARGET_INT_BIT - 2)) == 0)
+      && (un >> (TARGET_INT_BIT - 2)) == 0)
     {
       high_bit = ((unsigned LONGEST)1) << (TARGET_INT_BIT-1);
 
@@ -1038,7 +1042,7 @@ parse_number (p, len, parsed_float, putithere)
       signed_type = builtin_type_int;
     }
   else if (long_p <= 1
-          && (((unsigned LONGEST)n >> 2) >> (TARGET_LONG_BIT - 2)) == 0)
+          && (un >> (TARGET_LONG_BIT - 2)) == 0)
     {
       high_bit = ((unsigned LONGEST)1) << (TARGET_LONG_BIT-1);
       unsigned_type = builtin_type_unsigned_long;
@@ -1046,7 +1050,14 @@ parse_number (p, len, parsed_float, putithere)
     }
   else
     {
-      high_bit = ((unsigned LONGEST)1) << (TARGET_LONG_LONG_BIT - 1);
+      high_bit = (((unsigned LONGEST)1)
+                 << (TARGET_LONG_LONG_BIT - 32 - 1)
+                 << 16
+                 << 16);
+      if (high_bit == 0)
+       /* A long long does not fit in a LONGEST.  */
+       high_bit =
+         (unsigned LONGEST)1 << (sizeof (LONGEST) * HOST_CHAR_BIT - 1);
       unsigned_type = builtin_type_unsigned_long_long;
       signed_type = builtin_type_long_long;
     }
@@ -1514,7 +1525,11 @@ yylex ()
       }
     if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
         {
-#if 0
+#if 1
+         /* Despite the following flaw, we need to keep this code enabled.
+            Because we can get called from check_stub_method, if we don't
+            handle nested types then it screws many operations in any
+            program which uses nested types.  */
          /* In "A::x", if x is a member function of A and there happens
             to be a type (nested or not, since the stabs don't make that
             distinction) named x, then this code incorrectly thinks we
@@ -1559,7 +1574,7 @@ yylex ()
                      struct symbol *cur_sym;
                      /* As big as the whole rest of the expression, which is
                         at least big enough.  */
-                     char *tmp = alloca (strlen (namestart));
+                     char *tmp = alloca (strlen (namestart)+1);
 
                      memcpy (tmp, namestart, p - namestart);
                      tmp[p - namestart] = '\0';
@@ -1623,5 +1638,5 @@ void
 yyerror (msg)
      char *msg;
 {
-  error (msg ? msg : "Invalid syntax in expression.");
+  error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
 }
This page took 0.026863 seconds and 4 git commands to generate.