]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libiberty/cplus-dem.c
* cplus-dem.c (do_type): Handle volatile qualification.
[thirdparty/gcc.git] / libiberty / cplus-dem.c
index 21e3b6e1e0d867e9aabd5f87c5760a49b7db1273..ba3700c6db36d00b7ef2df0321dda8074d03fec3 100644 (file)
@@ -230,7 +230,7 @@ typedef struct string               /* Beware: these aren't required to be */
 static char *
 mop_up PARAMS ((struct work_stuff *, string *, int));
 
-static char *
+static void
 squangle_mop_up PARAMS ((struct work_stuff *));
 
 #if 0
@@ -239,7 +239,7 @@ demangle_method_args PARAMS ((struct work_stuff *, const char **, string *));
 #endif
 
 static char *
-internal_cplus_demangle PARAMS ((struct work_stuff *, const char *, int));
+internal_cplus_demangle PARAMS ((struct work_stuff *, const char *));
 
 static int
 demangle_template_template_parm PARAMS ((struct work_stuff *work, 
@@ -422,7 +422,7 @@ cplus_demangle_opname (opname, result, options)
      char *result;
      int options;
 {
-  int len, i, len1, ret;
+  int len, len1, ret;
   string type;
   struct work_stuff work[1];
   const char *tem;
@@ -430,6 +430,7 @@ cplus_demangle_opname (opname, result, options)
   len = strlen(opname);
   result[0] = '\0';
   ret = 0;
+  memset ((char *) work, 0, sizeof (work));
   work->options = options;
   
   if (opname[0] == '_' && opname[1] == '_'
@@ -453,6 +454,7 @@ cplus_demangle_opname (opname, result, options)
       if (opname[4] == '\0')
        {
          /* Operator.  */
+         size_t i;
          for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
            {
              if (strlen (optable[i].in) == 2
@@ -470,6 +472,7 @@ cplus_demangle_opname (opname, result, options)
          if (opname[2] == 'a' && opname[5] == '\0')
            {
              /* Assignment.  */
+             size_t i;
              for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
                {
                  if (strlen (optable[i].in) == 3
@@ -493,6 +496,7 @@ cplus_demangle_opname (opname, result, options)
       if (len >= 10 /* op$assign_ */
          && memcmp (opname + 3, "assign_", 7) == 0)
        {
+         size_t i;
          for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
            {
              len1 = len - 10;
@@ -509,6 +513,7 @@ cplus_demangle_opname (opname, result, options)
        }
       else
        {
+         size_t i;
          for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
            {
              len1 = len - 3;
@@ -551,7 +556,7 @@ cplus_mangle_opname (opname, options)
      const char *opname;
      int options;
 {
-  int i;
+  size_t i;
   int len;
 
   len = strlen (opname);
@@ -605,7 +610,7 @@ cplus_demangle (mangled, options)
   if ((work -> options & DMGL_STYLE_MASK) == 0)
     work -> options |= (int) current_demangling_style & DMGL_STYLE_MASK;
 
-  ret = internal_cplus_demangle (work, mangled, options);
+  ret = internal_cplus_demangle (work, mangled);
   squangle_mop_up (work);
   return (ret);
 }
@@ -618,10 +623,9 @@ cplus_demangle (mangled, options)
    calls go directly to this routine to avoid resetting that info. */
 
 static char *
-internal_cplus_demangle (work, mangled, options)
+internal_cplus_demangle (work, mangled)
      struct work_stuff *work;
      const char *mangled;
-     int options;
 {
 
   string decl;
@@ -679,7 +683,7 @@ internal_cplus_demangle (work, mangled, options)
 
 
 /* Clear out and squangling related storage */
-static char *
+static void
 squangle_mop_up (work)
      struct work_stuff *work;
 {
@@ -886,7 +890,8 @@ demangle_signature (work, mangled, declp)
            {
              remember_type (work, oldmangled, *mangled - oldmangled);
            }
-         string_append(&tname, (work -> options & DMGL_JAVA) ? "." : "::");
+           string_append (&tname, "::");
+
          string_prepends(declp, &tname);
          if (work -> destructor & 1)
            {
@@ -1340,7 +1345,7 @@ demangle_template_value_parm (work, mangled, s)
          char *p = xmalloc (symbol_len + 1), *q;
          strncpy (p, *mangled, symbol_len);
          p [symbol_len] = '\0';
-         q = internal_cplus_demangle (work, p, work->options);
+         q = internal_cplus_demangle (work, p);
          string_appendn (s, "&", 1);
          if (q)
            {
@@ -1370,7 +1375,6 @@ demangle_template (work, mangled, tname, trawname, is_type)
   int need_comma = 0;
   int success = 0;
   const char *start;
-  int is_java_array = 0;
   string temp;
 
   (*mangled)++;
@@ -1414,16 +1418,10 @@ demangle_template (work, mangled, tname, trawname, is_type)
            }
          if (trawname)
            string_appendn (trawname, *mangled, r);
-         is_java_array = (work -> options & DMGL_JAVA)
-           && strncmp (*mangled, "JArray1Z", 8) == 0;
-         if (! is_java_array)
-           {
              string_appendn (tname, *mangled, r);
-           }
          *mangled += r;
        }
     }
-  if (!is_java_array)
     string_append (tname, "<");
   /* get size of template parameter list */
   if (!get_count (mangled, &r))
@@ -1551,11 +1549,6 @@ demangle_template (work, mangled, tname, trawname, is_type)
        }
       need_comma = 1;
     }
-  if (is_java_array)
-    {
-      string_append (tname, "[]");
-    }
-  else
     {
       if (tname->p[-1] == '>')
        string_append (tname, " ");
@@ -1719,7 +1712,7 @@ demangle_class (work, mangled, declp)
        }
       remember_Ktype (work, class_name.b, LEN_STRING(&class_name));
       remember_Btype (work, class_name.b, LEN_STRING(&class_name), btype);
-      string_prepend (declp, (work -> options & DMGL_JAVA) ? "." : "::");
+       string_prepend (declp, "::");
       string_prepends (declp, &class_name);
       success = 1;
     }
@@ -2021,8 +2014,7 @@ gnu_special (work, mangled, declp)
            {
              if (p != NULL)
                {
-                 string_append (declp,
-                                (work -> options & DMGL_JAVA) ? "." : "::");
+                   string_append (declp, "::");
                  (*mangled)++;
                }
            }
@@ -2060,7 +2052,7 @@ gnu_special (work, mangled, declp)
          /* Consumed everything up to the cplus_marker, append the
             variable name.  */
          (*mangled)++;
-         string_append (declp, (work -> options & DMGL_JAVA) ? "." : "::");
+           string_append (declp, "::");
          n = strlen (*mangled);
          string_appendn (declp, *mangled, n);
          (*mangled) += n;
@@ -2073,7 +2065,7 @@ gnu_special (work, mangled, declp)
   else if (strncmp (*mangled, "__thunk_", 8) == 0)
     {
       int delta = ((*mangled) += 8, consume_count (mangled));
-      char *method = internal_cplus_demangle (work, ++*mangled, work->options);
+      char *method = internal_cplus_demangle (work, ++*mangled);
       if (method)
        {
          char buf[50];
@@ -2324,7 +2316,7 @@ demangle_qualified (work, mangled, result, isfuncname, append)
          success = do_type (work, mangled, &temp);
          if (!success) break;
        }
-      if (*mangled[0] == 'K')
+      else if (*mangled[0] == 'K')
        {
           int idx;
           (*mangled)++;
@@ -2357,7 +2349,7 @@ demangle_qualified (work, mangled, result, isfuncname, append)
 
       if (qualifiers > 0)
         {
-          string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::");
+           string_append (&temp, "::");
         }
     }
 
@@ -2368,7 +2360,7 @@ demangle_qualified (work, mangled, result, isfuncname, append)
 
   if (isfuncname && (work->constructor & 1 || work->destructor & 1))
     {
-      string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::");
+       string_append (&temp, "::");
       if (work -> destructor & 1)
        {
          string_append (&temp, "~");
@@ -2387,7 +2379,7 @@ demangle_qualified (work, mangled, result, isfuncname, append)
     {
       if (!STRING_EMPTY (result))
        {
-         string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::");
+           string_append (&temp, "::");
        }
       string_prepends (result, &temp);
     }
@@ -2482,7 +2474,6 @@ do_type (work, mangled, result)
        case 'P':
        case 'p':
          (*mangled)++;
-         if (! (work -> options & DMGL_JAVA))
            string_prepend (&decl, "*");
          break;
 
@@ -2565,7 +2556,7 @@ do_type (work, mangled, result)
              }
 
            string_append (&decl, ")");
-           string_prepend (&decl, (work -> options & DMGL_JAVA) ? "." : "::");
+             string_prepend (&decl, "::");
            if (isdigit (**mangled)) 
              {
                n = consume_count (mangled);
@@ -2637,7 +2628,7 @@ do_type (work, mangled, result)
          break;
 
        case 'C':
-         (*mangled)++;
+       case 'V':
          /*
            if ((*mangled)[1] == 'P')
            {
@@ -2648,8 +2639,10 @@ do_type (work, mangled, result)
                {
                  string_prepend (&decl, " ");
                }
-             string_prepend (&decl, "const");
+             string_prepend (&decl, 
+                             (**mangled) == 'C' ? "const" : "volatile");
            }
+         (*mangled)++;
          break;
          /*
            }
@@ -3618,7 +3611,6 @@ static struct option long_options[] = {
   {"strip-underscores", no_argument, 0, '_'},
   {"format", required_argument, 0, 's'},
   {"help", no_argument, 0, 'h'},
-  {"java", no_argument, 0, 'j'},
   {"no-strip-underscores", no_argument, 0, 'n'},
   {"version", no_argument, 0, 'v'},
   {0, no_argument, 0, 0}
@@ -3663,9 +3655,6 @@ main (argc, argv)
        case '_':
          strip_underscore = 1;
          break;
-       case 'j':
-         flags |= DMGL_JAVA;
-         break;
        case 's':
          if (strcmp (optarg, "gnu") == 0)
            {