Patchwork [Commited] Fix for PR59029

login
register
mail settings
Submitter Yury Gribov
Date Nov. 7, 2013, 12:32 p.m.
Message ID <527B8878.6060201@samsung.com>
Download mbox | patch
Permalink /patch/289307/
State New
Headers show

Comments

Yury Gribov - Nov. 7, 2013, 12:32 p.m.
Preapproved by Jakub in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59029
Marek Polacek - Nov. 7, 2013, 12:38 p.m.
On Thu, Nov 07, 2013 at 04:32:56PM +0400, Yury Gribov wrote:
> +	PR sanitizer/59029
> +	* gcc/asan.c (get_mem_refs_of_builtin_call): Allow
> +	integer literals as addresses in instrumented builtins.
> +

The prefix gcc/ hasn't been dropped as it should.

	Marek
Yury Gribov - Nov. 7, 2013, 12:48 p.m.
Yup, Jakub already pointed this out. Should I fix the changelog with 
another commit?

-----------------------------------------------
From: Marek Polacek <polacek@redhat.com>
Sent:  Thursday, November 07, 2013 4:38PM
To: Yury Gribov <y.gribov@samsung.com>
Cc: gcc-patches@gcc.gnu.org, Jakub Jelinek <jakub@redhat.com>, 
reichelt@gcc.gnu.org, Viacheslav Garbuzov <v.garbuzov@samsung.com>, 
Evgeny Gavrin <e.gavrin@samsung.com>
Subject: Re: [Commited] Fix for PR59029
On 11/07/2013 04:38 PM, Marek Polacek wrote:

On Thu, Nov 07, 2013 at 04:32:56PM +0400, Yury Gribov wrote:

> +	PR sanitizer/59029
> +	* gcc/asan.c (get_mem_refs_of_builtin_call): Allow
> +	integer literals as addresses in instrumented builtins.
> +

The prefix gcc/ hasn't been dropped as it should.

	Marek
Jakub Jelinek - Nov. 7, 2013, 12:49 p.m.
On Thu, Nov 07, 2013 at 04:48:10PM +0400, Yury Gribov wrote:
> Yup, Jakub already pointed this out. Should I fix the changelog with
> another commit?

Yes, just fix up the ChangeLog and commit, for ChangeLog changes
of course you don't add a new ChangeLog entry.

	Jakub
Yury Gribov - Nov. 7, 2013, 12:56 p.m.
>> Should I fix the changelog with another commit?
 > Yes, just fix up the ChangeLog and commit

Fixed.

-Y

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4991a3a..535b670 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@ 
+2013-11-07  Yury Gribov  <y.gribov@samsung.com>
+	    Jakub Jelinek  <jakub@redhat.com>
+
+	PR sanitizer/59029
+	* gcc/asan.c (get_mem_refs_of_builtin_call): Allow
+	integer literals as addresses in instrumented builtins.
+
 2013-11-07  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/59034
diff --git a/gcc/asan.c b/gcc/asan.c
index fdca377..950d332 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -715,7 +715,7 @@  get_mem_refs_of_builtin_call (const gimple call,
 	   instrument_derefs.  */
 	if (TREE_CODE (dest) == ADDR_EXPR)
 	  dest = TREE_OPERAND (dest, 0);
-	else if (TREE_CODE (dest) == SSA_NAME)
+	else if (TREE_CODE (dest) == SSA_NAME || TREE_CODE (dest) == INTEGER_CST)
 	  dest = build2 (MEM_REF, TREE_TYPE (TREE_TYPE (dest)),
 			 dest, build_int_cst (TREE_TYPE (dest), 0));
 	else
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 56d30a3..f6e735f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@ 
+2013-11-07  Yury Gribov  <y.gribov@samsung.com>
+	    Jakub Jelinek  <jakub@redhat.com>
+
+	PR sanitizer/59029
+	* c-c++-common/asan/pr59029.c: New test.
+
 2013-11-07  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/59034
diff --git a/gcc/testsuite/c-c++-common/asan/pr59029.c b/gcc/testsuite/c-c++-common/asan/pr59029.c
new file mode 100644
index 0000000..a1319b2
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/pr59029.c
@@ -0,0 +1,7 @@ 
+/* { dg-do compile } */
+
+int
+foo ()
+{
+  return __sync_fetch_and_add ((int *) 0, 1);
+}