This is essentially the same problem as in patch 2, but with unary '*'. We
should verify that its argument is a pointer.

-- 
Regards,
   Mikhail Maltsev


gcc/c/ChangeLog:

2017-05-01  Mikhail Maltsev  <malts...@gmail.com>

        * gimple-parser.c (c_parser_gimple_unary_expression): Check argument
        type of unary '*'.

gcc/testsuite/ChangeLog:

2017-05-01  Mikhail Maltsev  <malts...@gmail.com>

        * gcc.dg/gimplefe-error-8.c: New test.


From 3e0452e939e42af06365d7d49157c227f53a7522 Mon Sep 17 00:00:00 2001
From: Mikhail Maltsev <malts...@gmail.com>
Date: Fri, 24 Feb 2017 18:29:57 +0300
Subject: [PATCH 3/5] GIMPLEFE: handle invalid unary "*" operand type

---
 gcc/c/gimple-parser.c                   | 5 +++++
 gcc/testsuite/gcc.dg/gimplefe-error-8.c | 7 +++++++
 2 files changed, 12 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/gimplefe-error-8.c

diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c
index 2e11567..5249e8a 100644
--- a/gcc/c/gimple-parser.c
+++ b/gcc/c/gimple-parser.c
@@ -567,6 +567,11 @@ c_parser_gimple_unary_expression (c_parser *parser)
        op = c_parser_gimple_postfix_expression (parser);
        if (op.value == error_mark_node)
          return ret;
+       if (! POINTER_TYPE_P (TREE_TYPE (op.value)))
+         {
+           error_at (op_loc, "invalid type argument of unary %<*%>");
+           return ret;
+         }
        finish = op.get_finish ();
        location_t combined_loc = make_location (op_loc, op_loc, finish);
        ret.value = build_simple_mem_ref_loc (combined_loc, op.value);
diff --git a/gcc/testsuite/gcc.dg/gimplefe-error-8.c 
b/gcc/testsuite/gcc.dg/gimplefe-error-8.c
new file mode 100644
index 0000000..faf699d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gimplefe-error-8.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+__GIMPLE() void a()
+{
+  *0 = 1; /* { dg-error "invalid type" } */
+}
-- 
2.1.4

Reply via email to