Commit 9ee02b5c by Jeffrey A Law Committed by Jeff Law

* cplus-dem.c: Sync with gcc.

From-SVN: r19077
parent 96368631
Fri Apr 10 01:45:09 1998 Jeffrey A Law (law@cygnus.com)
* cplus-dem.c: Sync with gcc.
Thu Apr 2 13:53:54 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> Thu Apr 2 13:53:54 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* choose-temp.c: Include system.h when IN_GCC. * choose-temp.c: Include system.h when IN_GCC.
......
...@@ -29,9 +29,14 @@ Boston, MA 02111-1307, USA. */ ...@@ -29,9 +29,14 @@ Boston, MA 02111-1307, USA. */
try not to break either. */ try not to break either. */
#include <ctype.h> #include <ctype.h>
#include <sys/types.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <demangle.h> #include <demangle.h>
#undef CURRENT_DEMANGLING_STYLE #undef CURRENT_DEMANGLING_STYLE
#define CURRENT_DEMANGLING_STYLE work->options #define CURRENT_DEMANGLING_STYLE work->options
...@@ -224,6 +229,10 @@ demangle_method_args PARAMS ((struct work_stuff *work, const char **, string *)) ...@@ -224,6 +229,10 @@ demangle_method_args PARAMS ((struct work_stuff *work, const char **, string *))
#endif #endif
static int static int
demangle_template_template_parm PARAMS ((struct work_stuff *work,
const char **, string *));
static int
demangle_template PARAMS ((struct work_stuff *work, const char **, string *, demangle_template PARAMS ((struct work_stuff *work, const char **, string *,
string *, int)); string *, int));
...@@ -257,7 +266,7 @@ static int ...@@ -257,7 +266,7 @@ static int
gnu_special PARAMS ((struct work_stuff *, const char **, string *)); gnu_special PARAMS ((struct work_stuff *, const char **, string *));
static int static int
arm_special PARAMS ((struct work_stuff *, const char **, string *)); arm_special PARAMS ((const char **, string *));
static void static void
string_need PARAMS ((string *, int)); string_need PARAMS ((string *, int));
...@@ -347,7 +356,7 @@ consume_count (type) ...@@ -347,7 +356,7 @@ consume_count (type)
} }
/* Like consume_count, but for counts that are preceeded and followed /* Like consume_count, but for counts that are preceded and followed
by '_' if they are greater than 10. Also, -1 is returned for by '_' if they are greater than 10. Also, -1 is returned for
failure, since 0 can be a valid value. */ failure, since 0 can be a valid value. */
...@@ -843,7 +852,7 @@ demangle_signature (work, mangled, declp) ...@@ -843,7 +852,7 @@ demangle_signature (work, mangled, declp)
} }
else else
/* fall through */ /* fall through */
; {;}
default: default:
if (AUTO_DEMANGLING || GNU_DEMANGLING) if (AUTO_DEMANGLING || GNU_DEMANGLING)
...@@ -928,6 +937,70 @@ demangle_method_args (work, mangled, declp) ...@@ -928,6 +937,70 @@ demangle_method_args (work, mangled, declp)
#endif #endif
static int static int
demangle_template_template_parm (work, mangled, tname)
struct work_stuff *work;
const char **mangled;
string *tname;
{
int i;
int r;
int need_comma = 0;
int success = 1;
string temp;
string_append (tname, "template <");
/* get size of template parameter list */
if (get_count (mangled, &r))
{
for (i = 0; i < r; i++)
{
if (need_comma)
{
string_append (tname, ", ");
}
/* Z for type parameters */
if (**mangled == 'Z')
{
(*mangled)++;
string_append (tname, "class");
}
/* z for template parameters */
else if (**mangled == 'z')
{
(*mangled)++;
success =
demangle_template_template_parm (work, mangled, tname);
if (!success)
{
break;
}
}
else
{
/* temp is initialized in do_type */
success = do_type (work, mangled, &temp);
if (success)
{
string_appends (tname, &temp);
}
string_delete(&temp);
if (!success)
{
break;
}
}
need_comma = 1;
}
}
if (tname->p[-1] == '>')
string_append (tname, " ");
string_append (tname, "> class");
return (success);
}
static int
demangle_integral_value (work, mangled, s) demangle_integral_value (work, mangled, s)
struct work_stuff *work; struct work_stuff *work;
const char** mangled; const char** mangled;
...@@ -1212,19 +1285,50 @@ demangle_template (work, mangled, tname, trawname, is_type) ...@@ -1212,19 +1285,50 @@ demangle_template (work, mangled, tname, trawname, is_type)
{ {
start = *mangled; start = *mangled;
/* get template name */ /* get template name */
if ((r = consume_count (mangled)) == 0 || strlen (*mangled) < r) if (**mangled == 'z')
{ {
return (0); int idx;
(*mangled)++;
(*mangled)++;
idx = consume_count_with_underscores (mangled);
if (idx == -1
|| (work->tmpl_argvec && idx >= work->ntmpl_args)
|| consume_count_with_underscores (mangled) == -1)
{
return (0);
}
if (work->tmpl_argvec)
{
string_append (tname, work->tmpl_argvec[idx]);
if (trawname)
string_append (trawname, work->tmpl_argvec[idx]);
}
else
{
char buf[10];
sprintf(buf, "T%d", idx);
string_append (tname, buf);
if (trawname)
string_append (trawname, work->tmpl_argvec[idx]);
}
} }
if (trawname) else
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); if ((r = consume_count (mangled)) == 0 || strlen (*mangled) < r)
{
return (0);
}
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;
} }
*mangled += r;
} }
if (!is_java_array) if (!is_java_array)
string_append (tname, "<"); string_append (tname, "<");
...@@ -1272,6 +1376,33 @@ demangle_template (work, mangled, tname, trawname, is_type) ...@@ -1272,6 +1376,33 @@ demangle_template (work, mangled, tname, trawname, is_type)
break; break;
} }
} }
/* z for template parameters */
else if (**mangled == 'z')
{
int r2;
(*mangled)++;
success = demangle_template_template_parm (work, mangled, tname);
if (success
&& (r2 = consume_count (mangled)) > 0 && strlen (*mangled) >= r2)
{
string_append (tname, " ");
string_appendn (tname, *mangled, r2);
if (!is_type)
{
/* Save the template argument. */
int len = r2;
work->tmpl_argvec[i] = xmalloc (len + 1);
memcpy (work->tmpl_argvec[i], *mangled, len);
work->tmpl_argvec[i][len] = '\0';
}
*mangled += r2;
}
if (!success)
{
break;
}
}
else else
{ {
string param; string param;
...@@ -1644,7 +1775,7 @@ demangle_prefix (work, mangled, declp) ...@@ -1644,7 +1775,7 @@ demangle_prefix (work, mangled, declp)
then find the next "__" that separates the prefix from the signature. then find the next "__" that separates the prefix from the signature.
*/ */
if (!(ARM_DEMANGLING || LUCID_DEMANGLING) if (!(ARM_DEMANGLING || LUCID_DEMANGLING)
|| (arm_special (work, mangled, declp) == 0)) || (arm_special (mangled, declp) == 0))
{ {
while (*scan == '_') while (*scan == '_')
{ {
...@@ -1897,8 +2028,8 @@ LOCAL FUNCTION ...@@ -1897,8 +2028,8 @@ LOCAL FUNCTION
SYNOPSIS SYNOPSIS
static int static int
arm_special (struct work_stuff *work, const char **mangled, arm_special (const char **mangled,
string *declp); string *declp);
DESCRIPTION DESCRIPTION
...@@ -1912,8 +2043,7 @@ DESCRIPTION ...@@ -1912,8 +2043,7 @@ DESCRIPTION
*/ */
static int static int
arm_special (work, mangled, declp) arm_special (mangled, declp)
struct work_stuff *work;
const char **mangled; const char **mangled;
string *declp; string *declp;
{ {
...@@ -2409,7 +2539,6 @@ do_type (work, mangled, result) ...@@ -2409,7 +2539,6 @@ do_type (work, mangled, result)
/* A template parm. We substitute the corresponding argument. */ /* A template parm. We substitute the corresponding argument. */
{ {
int idx; int idx;
int lvl;
(*mangled)++; (*mangled)++;
idx = consume_count_with_underscores (mangled); idx = consume_count_with_underscores (mangled);
...@@ -2865,8 +2994,7 @@ demangle_function_name (work, mangled, declp, scan) ...@@ -2865,8 +2994,7 @@ demangle_function_name (work, mangled, declp, scan)
string *declp; string *declp;
const char *scan; const char *scan;
{ {
int i; size_t i;
int len;
string type; string type;
const char *tem; const char *tem;
...@@ -2913,7 +3041,7 @@ demangle_function_name (work, mangled, declp, scan) ...@@ -2913,7 +3041,7 @@ demangle_function_name (work, mangled, declp, scan)
{ {
for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
{ {
len = declp->p - declp->b - 10; int len = declp->p - declp->b - 10;
if (strlen (optable[i].in) == len if (strlen (optable[i].in) == len
&& memcmp (optable[i].in, declp->b + 10, len) == 0) && memcmp (optable[i].in, declp->b + 10, len) == 0)
{ {
...@@ -3223,6 +3351,15 @@ static struct option long_options[] = { ...@@ -3223,6 +3351,15 @@ static struct option long_options[] = {
{0, no_argument, 0, 0} {0, no_argument, 0, 0}
}; };
/* More 'friendly' abort that prints the line and file.
config.h can #define abort fancy_abort if you like that sort of thing. */
void
fancy_abort ()
{
fatal ("Internal gcc abort.");
}
int int
main (argc, argv) main (argc, argv)
int argc; int argc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment