Fixes related to handling of C++ methods (handle destructors

and parameters that are functions).
This commit is contained in:
Per Bothner 1991-11-12 22:20:02 +00:00
parent 5f12485297
commit 0e2a896cf5
5 changed files with 56 additions and 29 deletions

View File

@ -1,3 +1,27 @@
Tue Nov 12 13:43:26 1991 Per Bothner (bothner at cygnus.com)
* symtab.c (decode_line_1): Remove spurious call to operator_chars.
Allow setting breakpoints on C++ destructors.
* valops.c (destructor_name_p): Don't check TYPE_HAS_DESTRUCTOR,
since it lies. Rely on callers to catch missing destructors.
* symtab.c (decode_line_1): For example (see above), here.
* buildsym.c, symtab.h: Remove TYPE_FLAGS_HAS{CON,DE}STRUCTOR
flags since they are no longer used.
Fixes to support C++ methods with functional parameters.
* c-exp.y (func_mod rule): Allow (and ignore) list of parameter
types in a function type.
* eval.c (parse_and_eval_type), value.h: New function,
parse_and_eval_type, is based on old code from check_stub_method.
But don't actually evaluate the cast, since that calls
value_cast(), whcih may fail. Just extract the type
from the parsed expression.
* values.c (check_stub_method): While looping through the
arguments, adjust depth *after* parameter has been handled.
Replace call and setup of parse_and_eval with new function
parse_and_eval_type.
Tue Nov 12 09:40:07 1991 Fred Fish (fnf at cygnus.com)
* utils.c, rem-multi.shar: Remove fixed arg count version of

View File

@ -2383,20 +2383,10 @@ read_struct_type (pp, type)
{
*pp += 1;
if (**pp == '=')
if (**pp == '=' || **pp == '+' || **pp == '-')
{
TYPE_FLAGS (type)
|= TYPE_FLAG_HAS_CONSTRUCTOR | TYPE_FLAG_HAS_DESTRUCTOR;
*pp += 1;
}
else if (**pp == '+')
{
TYPE_FLAGS (type) |= TYPE_FLAG_HAS_CONSTRUCTOR;
*pp += 1;
}
else if (**pp == '-')
{
TYPE_FLAGS (type) |= TYPE_FLAG_HAS_DESTRUCTOR;
/* Obsolete flags that used to indicate the presence
of constructors and/or destructors. */
*pp += 1;
}

View File

@ -771,6 +771,8 @@ array_mod: '[' ']'
func_mod: '(' ')'
{ $$ = 0; }
| '(' nonempty_typelist ')'
{ free ($2); $$ = 0; }
;
type : ptype

View File

@ -1270,6 +1270,18 @@ lookup_partial_symbol (pst, name, global, namespace)
return (struct partial_symbol *) 0;
}
/* Find the psymtab containing main(). */
struct partial_symtab *
find_main_psymtab ()
{
register struct partial_symtab *pst;
for (pst = partial_symtab_list; pst; pst = pst->next)
if (lookup_partial_symbol (pst, "main", 1, VAR_NAMESPACE))
return pst;
return NULL;
}
/* Look for a symbol in block BLOCK. */
struct symbol *
@ -1930,7 +1942,6 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line)
}
while (p[0] == ' ' || p[0] == '\t') p++;
q = operator_chars (*argptr, &q1);
if (p[0] == ':')
{
@ -2043,7 +2054,12 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line)
}
else
tmp = copy;
error ("that class does not have any method named %s", tmp);
if (tmp[0] == '~')
error ("The class `%s' does not have destructor defined",
sym_class->name);
else
error ("The class %s does not have any method named %s",
sym_class->name, tmp);
}
}
else

View File

@ -1284,27 +1284,22 @@ check_stub_method (type, i, j)
if (*p != ')') /* () means no args, skip while */
{
depth = 0;
while (*p)
{
if (depth <= 0 && (*p == ',' || *p == ')'))
{
argtypes[argcount] =
parse_and_eval_type (argtypetext, p - argtypetext);
argcount += 1;
argtypetext = p + 1;
}
if (*p == '(')
depth += 1;
else if (*p == ')')
depth -= 1;
if (depth <= 0 && (*p == ',' || *p == ')'))
{
char *tmp = (char *)alloca (p - argtypetext + 4);
value val;
tmp[0] = '(';
bcopy (argtypetext, tmp+1, p - argtypetext);
tmp[p-argtypetext+1] = ')';
tmp[p-argtypetext+2] = '0';
tmp[p-argtypetext+3] = '\0';
val = parse_and_eval (tmp);
argtypes[argcount] = VALUE_TYPE (val);
argcount += 1;
argtypetext = p + 1;
}
p += 1;
}
}