GIMPLEFE: Handle invalid unary "*" operand type
authorMikhail Maltsev <maltsevm@gmail.com>
Thu, 11 May 2017 10:48:54 +0000 (10:48 +0000)
committerMikhail Maltsev <miyuki@gcc.gnu.org>
Thu, 11 May 2017 10:48:54 +0000 (10:48 +0000)
gcc/c/

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

gcc/testsuite/

PR testsuite/80580
* gcc.dg/gimplefe-error-4.c: New test.

From-SVN: r247899

gcc/c/ChangeLog
gcc/c/gimple-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/gimplefe-error-4.c [new file with mode: 0644]

index 5d6c6ef2ff2c375eeecb1cef2db262b8ddd2ffdd..ac05c3a2b76a780eb7b93ba90b29cbe0ff94e605 100644 (file)
@@ -1,3 +1,9 @@
+2017-05-11  Mikhail Maltsev  <maltsevm@gmail.com>
+
+       PR testsuite/80580
+       * gimple-parser.c (c_parser_gimple_unary_expression): Check argument
+       type of unary '*'.
+
 2017-05-09  Nathan Sidwell  <nathan@acm.org>
 
        * c-tree.h (pushdecl): Declare.
index 0d6384b55c23edf7b987e55521ef1d61963e6589..c6c2f7aa5dc24999cd0b47486f28376bfed843e9 100644 (file)
@@ -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, "expected pointer as 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);
index d7d1d04cb6937c0a5a12c57cad0140388a59154c..dfd8670e8be5e2728942413490ef28558039c9e8 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-11  Mikhail Maltsev  <maltsevm@gmail.com>
+
+       PR testsuite/80580
+       * gcc.dg/gimplefe-error-4.c: New test.
+
 2017-05-10  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        * gcc.target/powerpc/p8-vec-xl-xst.c: New file.
diff --git a/gcc/testsuite/gcc.dg/gimplefe-error-4.c b/gcc/testsuite/gcc.dg/gimplefe-error-4.c
new file mode 100644 (file)
index 0000000..b2ca796
--- /dev/null
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+__GIMPLE() void a()
+{
+  *0 = 1; /* { dg-error "expected pointer" } */
+}