diff options
author | Tom Tromey <tromey@redhat.com> | 2012-07-09 14:20:52 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-07-09 14:20:52 +0000 |
commit | e314d62968dfb4ae82c70dbe68d9d4ec929deb7e (patch) | |
tree | b66865521e10da3ab58c11932c46a5715cf499af /gdb/c-exp.y | |
parent | 1416057852c2649d2c3d0636b4e6007f3bc2d043 (diff) | |
download | gdb-e314d62968dfb4ae82c70dbe68d9d4ec929deb7e.zip gdb-e314d62968dfb4ae82c70dbe68d9d4ec929deb7e.tar.gz gdb-e314d62968dfb4ae82c70dbe68d9d4ec929deb7e.tar.bz2 |
* c-exp.y (check_parameter_typelist): New function.
(parameter_typelist): Call it.
* eval.c (make_params): Handle '(void)' case.
* gdbtypes.c (lookup_function_type_with_arguments): Handle
'(void)' case.
testsuite
* gdb.base/whatis.exp: Add error checks for improper 'void' uses.
* gdb.base/callfuncs.exp: Add cast-based test.
* gdb.base/callfuncs.c (voidfunc): New function.
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r-- | gdb/c-exp.y | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 14fd53d..0613799 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -165,6 +165,7 @@ void yyerror (char *); /* YYSTYPE gets defined by %union */ static int parse_number (char *, int, int, YYSTYPE *); static struct stoken operator_stoken (const char *); +static void check_parameter_typelist (VEC (type_ptr) *); %} %type <voidval> exp exp1 type_exp start variable qualified_name lcurly @@ -1227,9 +1228,11 @@ typename: TYPENAME parameter_typelist: nonempty_typelist + { check_parameter_typelist ($1); } | nonempty_typelist ',' DOTDOTDOT { VEC_safe_push (type_ptr, $1, NULL); + check_parameter_typelist ($1); $$ = $1; } ; @@ -1444,6 +1447,37 @@ operator_stoken (const char *op) return st; }; +/* Validate a parameter typelist. */ + +static void +check_parameter_typelist (VEC (type_ptr) *params) +{ + struct type *type; + int ix; + + for (ix = 0; VEC_iterate (type_ptr, params, ix, type); ++ix) + { + if (type != NULL && TYPE_CODE (check_typedef (type)) == TYPE_CODE_VOID) + { + if (ix == 0) + { + if (VEC_length (type_ptr, params) == 1) + { + /* Ok. */ + break; + } + VEC_free (type_ptr, params); + error (_("parameter types following 'void'")); + } + else + { + VEC_free (type_ptr, params); + error (_("'void' invalid as parameter type")); + } + } + } +} + /* Take care of parsing a number (anything that starts with a digit). Set yylval and return the token type; update lexptr. LEN is the number of characters in it. */ |