From: Oleg Nesterov <oleg@redhat.com>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Cc: Alexey Gladkov <gladkov.alexey@gmail.com>, linux-sparse@vger.kernel.org
Subject: [PATCH] dissect: support _Generic() a bit more
Date: Thu, 30 Jul 2020 17:09:58 +0200 [thread overview]
Message-ID: <20200730150958.GB6956@redhat.com> (raw)
In-Reply-To: <20200728231058.3yakpfw3dqslxq5t@ltop.local>
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>
---
dissect.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/dissect.c b/dissect.c
index a633c8bf..fd09707d 100644
--- a/dissect.c
+++ b/dissect.c
@@ -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);
}
--
2.25.1.362.g51ebf55
next prev parent reply other threads:[~2020-07-30 15:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 18:35 [PATCH] dissect: add support for _Generic Alexey Gladkov
2020-07-28 19:49 ` Oleg Nesterov
2020-07-28 23:10 ` Luc Van Oostenryck
2020-07-29 11:28 ` Oleg Nesterov
2020-07-29 14:50 ` Luc Van Oostenryck
2020-07-30 15:08 ` Oleg Nesterov
2020-07-30 20:00 ` Luc Van Oostenryck
2020-07-31 14:43 ` Oleg Nesterov
2020-07-31 16:13 ` Luc Van Oostenryck
2020-07-30 15:09 ` Oleg Nesterov [this message]
2020-07-30 20:05 ` [PATCH] dissect: support _Generic() a bit more Luc Van Oostenryck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200730150958.GB6956@redhat.com \
--to=oleg@redhat.com \
--cc=gladkov.alexey@gmail.com \
--cc=linux-sparse@vger.kernel.org \
--cc=luc.vanoostenryck@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).