From 67ac9a9db1b63e93fcdc2d959325c984edd521b8 Mon Sep 17 00:00:00 2001 From: Mikhail Maltsev Date: Thu, 11 May 2017 10:55:52 +0000 Subject: [PATCH] GIMPLEFE: handle invalid __MEM gcc/c/ PR testsuite/80580 * gimple-parser.c (c_parser_gimple_postfix_expression): Handle incorrect __MEM syntax. gcc/testsuite/ PR testsuite/80580 * gcc.dg/gimplefe-error-5.c: New test. From-SVN: r247900 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/gimple-parser.c | 10 ++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/gimplefe-error-5.c | 7 +++++++ 4 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/gimplefe-error-5.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index ac05c3a2b76..3bf4db20b9b 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2017-05-11 Mikhail Maltsev + + PR testsuite/80580 + * gimple-parser.c (c_parser_gimple_postfix_expression): Handle + incorrect __MEM syntax. + 2017-05-11 Mikhail Maltsev PR testsuite/80580 diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index c6c2f7aa5dc..c0858b709aa 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -804,6 +804,16 @@ c_parser_gimple_postfix_expression (c_parser *parser) } } ptr = c_parser_gimple_unary_expression (parser); + if (ptr.value == error_mark_node + || ! POINTER_TYPE_P (TREE_TYPE (ptr.value))) + { + if (ptr.value != error_mark_node) + error_at (ptr.get_start (), + "invalid type of %<__MEM%> operand"); + c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, + "expected %<)%>"); + return expr; + } if (! alias_type) alias_type = TREE_TYPE (ptr.value); /* Optional constant offset. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dfd8670e8be..393d8803e8f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-05-11 Mikhail Maltsev + + PR testsuite/80580 + * gcc.dg/gimplefe-error-5.c: New test. + 2017-05-11 Mikhail Maltsev PR testsuite/80580 diff --git a/gcc/testsuite/gcc.dg/gimplefe-error-5.c b/gcc/testsuite/gcc.dg/gimplefe-error-5.c new file mode 100644 index 00000000000..2bdb3982525 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-error-5.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +__GIMPLE() void a() +{ + __MEM() = 0; /* { dg-error "expected .<." } */ +} -- 2.30.2