From e314d62968dfb4ae82c70dbe68d9d4ec929deb7e Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 9 Jul 2012 14:20:52 +0000 Subject: * 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. --- gdb/c-exp.y | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'gdb/c-exp.y') diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 14fd53d232..0613799c27 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 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. */ -- cgit v1.2.1