diff options
author | Oleg Nesterov <oleg@redhat.com> | 2020-07-30 17:09:58 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-30 21:29:12 +0200 |
commit | 6701c7769965b8882a89d2db58f29e364b3501f2 (patch) | |
tree | 1cd3e26384a6b501ab433f5af1a7a5d148cd4252 | |
parent | 4932334a3205c913e61587518539a44a0941a2ef (diff) | |
download | sparse-6701c7769965b8882a89d2db58f29e364b3501f2.tar.gz |
dissect: support _Generic() a bit more
Change do_expression(EXPR_GENERIC) to inspect expr->control/map/def.
The is the minimal "better than nothing" change, technically incorrect
but still useful for the indexing.
Example:
void func(void)
{
_Generic(a,
int: b,
void: c,
default: d,
) = e;
}
output:
1:6 def f func void ( ... )
3:18 func --- v a bad type
4:33 func -w- v b bad type
5:33 func -w- v c bad type
6:33 func -w- v d bad type
7:13 func -r- v e bad type
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | dissect.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -342,7 +342,6 @@ again: case EXPR_TYPE: // [struct T]; Why ??? case EXPR_VALUE: case EXPR_FVALUE: - case EXPR_GENERIC: break; case EXPR_LABEL: ret = &label_ctype; @@ -472,6 +471,17 @@ again: } while ((expr = expr->down)); } + break; case EXPR_GENERIC: { + struct type_expression *map; + + do_expression(U_VOID, expr->control); + + for (map = expr->map; map; map = map->next) + ret = do_expression(mode, map->expr); + if (expr->def) + ret = do_expression(mode, expr->def); + } + break; case EXPR_SYMBOL: ret = report_symbol(mode, expr); } |