aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2022-06-09 11:11:09 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2022-06-09 11:11:09 +0200
commit9212270048c3bd23f56c20a83d4f89b870b2b26e (patch)
tree3785b539c4787497f38770cd6fbc3b56afe226ba
parent29083a76efa600b02d30f32d0393ae53e37887f8 (diff)
parent53e04b3b780bbcf2dd3eb7990c17414742bbfef9 (diff)
downloadsparse-9212270048c3bd23f56c20a83d4f89b870b2b26e.tar.gz
Merge branches 'cgcc-dash-x' and 'fixes'
* cgcc: do not die on '-x assembler' * fix crash when inlining casts of erroneous expressions - allow show_token() on TOKEN_ZERO_IDENT
-rw-r--r--inline.c2
-rw-r--r--tokenize.c2
-rw-r--r--validation/inline-early/bug-bad-token.c15
3 files changed, 19 insertions, 0 deletions
diff --git a/inline.c b/inline.c
index eceef8ba..0097e4bf 100644
--- a/inline.c
+++ b/inline.c
@@ -155,6 +155,8 @@ static struct expression * copy_expression(struct expression *expr)
/* Cast/sizeof/__alignof__ */
case EXPR_CAST:
+ if (!expr->cast_expression)
+ return NULL;
if (expr->cast_expression->type == EXPR_INITIALIZER) {
struct expression *cast = expr->cast_expression;
struct symbol *sym = expr->cast_type;
diff --git a/tokenize.c b/tokenize.c
index ea710543..fdaea370 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -201,6 +201,7 @@ const char *show_token(const struct token *token)
return "end-of-input";
case TOKEN_IDENT:
+ case TOKEN_ZERO_IDENT:
return show_ident(token->ident);
case TOKEN_NUMBER:
@@ -259,6 +260,7 @@ const char *quote_token(const struct token *token)
return "syntax error";
case TOKEN_IDENT:
+ case TOKEN_ZERO_IDENT:
return show_ident(token->ident);
case TOKEN_NUMBER:
diff --git a/validation/inline-early/bug-bad-token.c b/validation/inline-early/bug-bad-token.c
new file mode 100644
index 00000000..9049bdb4
--- /dev/null
+++ b/validation/inline-early/bug-bad-token.c
@@ -0,0 +1,15 @@
+inline void fun(int x)
+{
+ (typeof(@)) x;
+}
+
+void foo(void)
+{
+ fun;
+}
+
+/*
+ * check-name: bug-bad-token
+ * check-exit-value: 0
+ * check-error-ignore
+ */