mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[qfcc] Catch several useless specifier expressions
This commit is contained in:
parent
597890dda1
commit
4c82114547
1 changed files with 26 additions and 1 deletions
|
@ -285,6 +285,13 @@ is_anonymous_struct (specifier_t spec)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
is_null_spec (specifier_t spec)
|
||||
{
|
||||
static specifier_t null_spec;
|
||||
return memcmp (&spec, &null_spec, sizeof (spec)) == 0;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%expect 0
|
||||
|
@ -333,7 +340,25 @@ external_def_list
|
|||
|
||||
external_def
|
||||
: optional_specifiers external_decl_list ';' { }
|
||||
| optional_specifiers ';' { }
|
||||
| optional_specifiers ';'
|
||||
{
|
||||
if (!is_null_spec ($1)) {
|
||||
if (!$1.type && !$1.sym) {
|
||||
warning (0, "useless specifiers");
|
||||
} else if ($1.type && !$1.sym) {
|
||||
if (is_anonymous_struct ($1)){
|
||||
warning (0, "unnamed struct/union that defines "
|
||||
"no instances");
|
||||
} else {
|
||||
warning (0, "useless type name in empty declaration");
|
||||
}
|
||||
} else if (!$1.type && $1.sym) {
|
||||
bug (0, "wha? %p %p", $1.type, $1.sym);
|
||||
} else {
|
||||
bug (0, "wha? %p %p", $1.type, $1.sym);
|
||||
}
|
||||
}
|
||||
}
|
||||
| optional_specifiers qc_func_params
|
||||
{
|
||||
type_t **type;
|
||||
|
|
Loading…
Reference in a new issue