public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 5/5][GIMPLE FE] PR testsuite/80580: Handle invalid SSA names
@ 2017-05-01 18:09 Mikhail Maltsev
  2017-05-02 14:32 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Mikhail Maltsev @ 2017-05-01 18:09 UTC (permalink / raw)
  To: gcc-patches, Richard Biener, Prathamesh Kulkarni

[-- Attachment #1: Type: text/plain, Size: 452 bytes --]

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  <maltsevm@gmail.com>

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


gcc/c/ChangeLog:

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

	* gimple-parser.c (c_parser_parse_ssa_name): Validate SSA name base.



[-- Attachment #2: 0005-GIMPLEFE-Handle-invalid-SSA-names.patch --]
[-- Type: text/plain, Size: 1513 bytes --]

From bae6cf05131c284fc8ae9a02f2ba99d447d04fd2 Mon Sep 17 00:00:00 2001
From: Mikhail Maltsev <maltsevm@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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 5/5][GIMPLE FE] PR testsuite/80580: Handle invalid SSA names
  2017-05-01 18:09 [PATCH 5/5][GIMPLE FE] PR testsuite/80580: Handle invalid SSA names Mikhail Maltsev
@ 2017-05-02 14:32 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-05-02 14:32 UTC (permalink / raw)
  To: Mikhail Maltsev; +Cc: gcc-patches, Prathamesh Kulkarni

On Mon, May 1, 2017 at 8:09 PM, Mikhail Maltsev <maltsevm@gmail.com> wrote:
> 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'.

+         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;
+           }

please drop || (TYPE_P (parent) && is_gimple_reg_type (parent))), that
case isn't valid.
Please also change wording slightly to "invalid base %qE for SSA name".

Ok with that changes.

Thanks,
Richard.

> --
> Regards,
>    Mikhail Maltsev
>
>
> gcc/testsuite/ChangeLog:
>
> 2017-05-01  Mikhail Maltsev  <maltsevm@gmail.com>
>
>         * gcc.dg/gimplefe-error-11.c: New test.
>
>
> gcc/c/ChangeLog:
>
> 2017-05-01  Mikhail Maltsev  <maltsevm@gmail.com>
>
>         * gimple-parser.c (c_parser_parse_ssa_name): Validate SSA name base.
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-02 14:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-01 18:09 [PATCH 5/5][GIMPLE FE] PR testsuite/80580: Handle invalid SSA names Mikhail Maltsev
2017-05-02 14:32 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).