import gdb-1999-08-23 snapshot
[deliverable/binutils-gdb.git] / gdb / stabsread.c
index ec59cf36bd08f22464cf40f6e0d90bb2210c195b..464fce1701da36888920ca2328f670f39a992404 100644 (file)
@@ -194,6 +194,8 @@ static CORE_ADDR
 static int
 resolve_symbol_reference PARAMS ((struct objfile *, struct symbol *, char *));
 
+void stabsread_clear_cache PARAMS ((void));
+
 static const char vptr_name[] =
 {'_', 'v', 'p', 't', 'r', CPLUS_MARKER, '\0'};
 static const char vb_name[] =
@@ -1192,6 +1194,16 @@ static int ref_count = 0;
 /* Number of chunks malloced. */
 static int ref_chunk = 0;
 
+/* This file maintains a cache of stabs aliases found in the symbol
+   table. If the symbol table changes, this cache must be cleared
+   or we are left holding onto data in invalid obstacks. */
+void
+stabsread_clear_cache ()
+{
+  ref_count = 0;
+  ref_chunk = 0;
+}
+
 /* Create array of pointers mapping refids to symbols and stab strings.
    Add pointers to reference definition symbols and/or their values as we 
    find them, using their reference numbers as our index. 
@@ -3712,7 +3724,8 @@ read_baseclasses (fip, pp, type, objfile)
          {
            static struct complaint msg =
            {
-             "Unknown visibility `%c' for baseclass", 0, 0};
+             "Unknown visibility `%c' for baseclass", 0, 0
+           };
            complain (&msg, new->visibility);
            new->visibility = VISIBILITY_PUBLIC;
          }
@@ -4701,18 +4714,30 @@ read_range_type (pp, typenums, objfile)
   /* We used to do this only for subrange of self or subrange of int.  */
   else if (n2 == 0)
     {
+      /* -1 is used for the upper bound of (4 byte) "unsigned int" and
+         "unsigned long", and we already checked for that,
+         so don't need to test for it here.  */
+
       if (n3 < 0)
        /* n3 actually gives the size.  */
        return init_type (TYPE_CODE_INT, -n3, TYPE_FLAG_UNSIGNED,
                          NULL, objfile);
-      if (n3 == 0xff)
-       return init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED, NULL, objfile);
-      if (n3 == 0xffff)
-       return init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED, NULL, objfile);
 
-      /* -1 is used for the upper bound of (4 byte) "unsigned int" and
-         "unsigned long", and we already checked for that,
-         so don't need to test for it here.  */
+      /* Is n3 == 2**(8n)-1 for some integer n?  Then it's an
+         unsigned n-byte integer.  But do require n to be a power of
+         two; we don't want 3- and 5-byte integers flying around.  */
+      {
+       int bytes;
+       unsigned long bits;
+
+       bits = n3;
+       for (bytes = 0; (bits & 0xff) == 0xff; bytes++)
+         bits >>= 8;
+       if (bits == 0
+           && ((bytes - 1) & bytes) == 0) /* "bytes is a power of two" */
+         return init_type (TYPE_CODE_INT, bytes, TYPE_FLAG_UNSIGNED, NULL,
+                           objfile);
+      }
     }
   /* I think this is for Convex "long long".  Since I don't know whether
      Convex sets self_subrange, I also accept that particular size regardless
This page took 0.024022 seconds and 4 git commands to generate.