diff options
author | Tom Tromey <tromey@redhat.com> | 2012-07-09 14:20:48 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2012-07-09 14:20:48 +0000 |
commit | f73e194501a969c66208d4c0dccbeab487b20719 (patch) | |
tree | a9a7570edb14ba5052b58606757cb179847b17b7 /gdb/c-exp.y | |
parent | 3f13479af4ae1943886ca66b239de2b211ad43f4 (diff) | |
download | gdb-f73e194501a969c66208d4c0dccbeab487b20719.tar.gz |
* 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 14fd53d232b..0613799c27e 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. */ |