From c587104e114652bea492bebbbc8373852578df69 Mon Sep 17 00:00:00 2001 From: Mikhail Maltsev Date: Thu, 11 May 2017 12:27:37 +0000 Subject: [PATCH] GIMPLEFE: Handle invalid SSA names gcc/testsuite/ PR testsuite/80580 * gcc.dg/gimplefe-error-6.c: New test. gcc/c/ PR testsuite/80580 * gimple-parser.c (c_parser_parse_ssa_name): Validate SSA name base. From-SVN: r247903 --- gcc/c/ChangeLog | 5 +++++ gcc/c/gimple-parser.c | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/gimplefe-error-6.c | 9 +++++++++ 4 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/gimplefe-error-6.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 3bf4db20b9b..69b1ac30813 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2017-05-11 Mikhail Maltsev + + PR testsuite/80580 + * gimple-parser.c (c_parser_parse_ssa_name): Validate SSA name base. + 2017-05-11 Mikhail Maltsev PR testsuite/80580 diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index c0858b709aa..ed9e7c55f0a 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -692,6 +692,13 @@ 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)) + { + error ("invalid base %qE for SSA name", 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/ChangeLog b/gcc/testsuite/ChangeLog index 393d8803e8f..2b5f6aca067 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-6.c: New test. + 2017-05-11 Mikhail Maltsev PR testsuite/80580 diff --git a/gcc/testsuite/gcc.dg/gimplefe-error-6.c b/gcc/testsuite/gcc.dg/gimplefe-error-6.c new file mode 100644 index 00000000000..c73b85c1e24 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-error-6.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +void a(int); + +__GIMPLE() void b() +{ + a_2 = 0; /* { dg-error "invalid" } */ +} -- 2.30.2