aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/gimple-parser.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-10-15 08:52:08 +0200
committerRichard Biener <rguenther@suse.de>2021-10-15 09:34:07 +0200
commit17ffb7a562061c54eb6eb9863271524568761cf6 (patch)
tree0b1251324aae4d81e4828d2226783e037a108421 /gcc/c/gimple-parser.c
parent11a4714860d2df6ba496d55379e7dc702d5fc425 (diff)
downloadgcc-17ffb7a562061c54eb6eb9863271524568761cf6.zip
gcc-17ffb7a562061c54eb6eb9863271524568761cf6.tar.gz
gcc-17ffb7a562061c54eb6eb9863271524568761cf6.tar.bz2
c/102763 - fix ICE with invalid input to GIMPLE FE
This fixes an ICE for the failure to verify we're dereferencing a pointer before throwing that at build_simple_mem_ref. 2021-10-15 Richard Biener <rguenther@suse.de> PR c/102763 gcc/c/ * gimple-parser.c (c_parser_gimple_postfix_expression_after_primary): Check for a pointer do be dereferenced by ->. gcc/testsuite/ * gcc.dg/gimplefe-error-12.c: New testcase.
Diffstat (limited to 'gcc/c/gimple-parser.c')
-rw-r--r--gcc/c/gimple-parser.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c
index c43ee38..f3d9935 100644
--- a/gcc/c/gimple-parser.c
+++ b/gcc/c/gimple-parser.c
@@ -1817,6 +1817,14 @@ c_parser_gimple_postfix_expression_after_primary (gimple_parser &parser,
case CPP_DEREF:
{
/* Structure element reference. */
+ if (!POINTER_TYPE_P (TREE_TYPE (expr.value)))
+ {
+ c_parser_error (parser, "dereference of non-pointer");
+ expr.set_error ();
+ expr.original_code = ERROR_MARK;
+ expr.original_type = NULL;
+ return expr;
+ }
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_NAME))
{