public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: gcc-patches@gcc.gnu.org
Cc: Marek Polacek <polacek@redhat.com>
Subject: [PATCH] Fix fallthrough attribute ignorance w/ -fsanitize=address (PR sanitizer/82792).
Date: Wed, 08 Nov 2017 07:23:00 -0000	[thread overview]
Message-ID: <a0c79867-a755-fcb8-e2a7-a7ca0d2aca66@suse.cz> (raw)

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

Hello.

Quite simple patch that ignores IFN_ASAN_CHECK call that is introduced in gimplifier.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

gcc/ChangeLog:

2017-11-07  Martin Liska  <mliska@suse.cz>

	PR sanitizer/82792
	* gimplify.c (expand_FALLTHROUGH_r): Skip IFN_ASAN_MARK.

gcc/testsuite/ChangeLog:

2017-11-07  Martin Liska  <mliska@suse.cz>

	PR sanitizer/82792
	* g++.dg/asan/pr82792.C: New test.
---
 gcc/gimplify.c                      |  8 ++++++--
 gcc/testsuite/g++.dg/asan/pr82792.C | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/asan/pr82792.C



[-- Attachment #2: 0001-Fix-fallthrough-attribute-ignorance-w-fsanitize-addr.patch --]
[-- Type: text/x-patch, Size: 1583 bytes --]

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index c4fd5038d92..9563d825a6a 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -2223,7 +2223,8 @@ expand_FALLTHROUGH_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
 	  while (!gsi_end_p (gsi2))
 	    {
 	      stmt = gsi_stmt (gsi2);
-	      if (gimple_code (stmt) == GIMPLE_LABEL)
+	      enum gimple_code gc = gimple_code (stmt);
+	      if (gc == GIMPLE_LABEL)
 		{
 		  tree label = gimple_label_label (as_a <glabel *> (stmt));
 		  if (gimple_has_location (stmt) && DECL_ARTIFICIAL (label))
@@ -2232,8 +2233,11 @@ expand_FALLTHROUGH_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p,
 		      break;
 		    }
 		}
+	      else if (gc == GIMPLE_CALL
+		       && gimple_call_internal_p (stmt, IFN_ASAN_MARK))
+		;
 	      else
-		/* Something other than a label.  That's not expected.  */
+		/* Something other is not expected.  */
 		break;
 	      gsi_next (&gsi2);
 	    }
diff --git a/gcc/testsuite/g++.dg/asan/pr82792.C b/gcc/testsuite/g++.dg/asan/pr82792.C
new file mode 100644
index 00000000000..99f1c35328c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/pr82792.C
@@ -0,0 +1,32 @@
+/* PR sanitizer/82792 */
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=address" } */
+
+extern int
+test (int i, int j)
+{
+  long c;
+  (c) = 1;
+  switch (i)
+    {
+    case 1:
+      if (j)
+	{
+	  c = 1;
+	}
+      goto default_case;
+    case 2:
+      {
+	if (j)
+	  {
+	    c = 0;
+	  }
+      }
+      __attribute ((fallthrough));
+    default_case:
+    default:
+      c = 0;
+      break;
+    }
+  return 0;
+}


             reply	other threads:[~2017-11-08  7:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08  7:23 Martin Liška [this message]
2017-11-08  8:01 ` Jakub Jelinek
2017-11-08  8:46 ` Marek Polacek
2017-11-08 11:44   ` Martin Liška
2017-11-08 11:48     ` Marek Polacek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a0c79867-a755-fcb8-e2a7-a7ca0d2aca66@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=polacek@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).