When parsing SSA names, we should check that parent names are scalars. In fact, this patch just uses the condition of a 'gcc_assert' in 'make_ssa_name_fn'.
-- Regards, Mikhail Maltsev gcc/testsuite/ChangeLog: 2017-05-01 Mikhail Maltsev <malts...@gmail.com> * gcc.dg/gimplefe-error-11.c: New test. gcc/c/ChangeLog: 2017-05-01 Mikhail Maltsev <malts...@gmail.com> * gimple-parser.c (c_parser_parse_ssa_name): Validate SSA name base.
From bae6cf05131c284fc8ae9a02f2ba99d447d04fd2 Mon Sep 17 00:00:00 2001 From: Mikhail Maltsev <malts...@gmail.com> Date: Fri, 24 Feb 2017 20:54:40 +0300 Subject: [PATCH 5/5] GIMPLEFE: Handle invalid SSA names --- gcc/c/gimple-parser.c | 8 ++++++++ gcc/testsuite/gcc.dg/gimplefe-error-11.c | 9 +++++++++ 2 files changed, 17 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/gimplefe-error-11.c diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index f3af840..ac8e7a7 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -692,6 +692,14 @@ c_parser_parse_ssa_name (c_parser *parser, c_parser_error (parser, "base variable or SSA name undeclared"); return error_mark_node; } + if (!(VAR_P (parent) + || TREE_CODE (parent) == PARM_DECL + || TREE_CODE (parent) == RESULT_DECL + || (TYPE_P (parent) && is_gimple_reg_type (parent)))) + { + error ("invalid SSA name %qE", parent); + return error_mark_node; + } if (VECTOR_TYPE_P (TREE_TYPE (parent)) || TREE_CODE (TREE_TYPE (parent)) == COMPLEX_TYPE) DECL_GIMPLE_REG_P (parent) = 1; diff --git a/gcc/testsuite/gcc.dg/gimplefe-error-11.c b/gcc/testsuite/gcc.dg/gimplefe-error-11.c new file mode 100644 index 0000000..c73b85c --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-error-11.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void a(int); + +__GIMPLE() void b() +{ + a_2 = 0; /* { dg-error "invalid" } */ +} -- 2.1.4