Patchwork PR middle-end/51696: display indirect function calls properly for trans-mem

login
register
mail settings
Submitter Aldy Hernandez
Date Jan. 3, 2012, 9:19 p.m.
Message ID <4F0370ED.7010302@redhat.com>
Download mbox | patch
Permalink /patch/134085/
State New
Headers show

Comments

Aldy Hernandez - Jan. 3, 2012, 9:19 p.m.
On 01/03/12 14:01, Richard Henderson wrote:
> On 01/04/2012 04:18 AM, Aldy Hernandez wrote:
>> 	PR middle-end/51696
>> 	* trans-mem.c (diagnose_tm_1): Display indirect calls with no name
>> 	correctly.
>
> Ok.
>
>
> r~

Sorry for the noise, but I forgot to check that we actually have a DECL. 
  Patch updated and tested on x86-64 Linux.

Still OK?
PR middle-end/51696
	* trans-mem.c (diagnose_tm_1): Display indirect calls with no name
	correctly.
Richard Henderson - Jan. 3, 2012, 9:23 p.m.
On 01/04/2012 08:19 AM, Aldy Hernandez wrote:
> 	PR middle-end/51696
> 	* trans-mem.c (diagnose_tm_1): Display indirect calls with no name
> 	correctly.

Ok.


r~

Patch

Index: testsuite/gcc.dg/tm/pr51696.c
===================================================================
--- testsuite/gcc.dg/tm/pr51696.c	(revision 0)
+++ testsuite/gcc.dg/tm/pr51696.c	(revision 0)
@@ -0,0 +1,14 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm" } */
+
+struct list {
+  void (*compare)();
+} *listPtr;
+
+static void (*compare)();
+
+__attribute__((transaction_safe))
+static void func () {
+  listPtr->compare(); /* { dg-error "unsafe indirect function call" } */
+  compare(); /* { dg-error "unsafe function call" } */
+}
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 182848)
+++ trans-mem.c	(working copy)
@@ -664,9 +664,16 @@  diagnose_tm_1 (gimple_stmt_iterator *gsi
 				"unsafe function call %qD within "
 				"atomic transaction", fn);
 		    else
-		      error_at (gimple_location (stmt),
-				"unsafe function call %qE within "
-				"atomic transaction", fn);
+		      {
+			if (!DECL_P (fn) || DECL_NAME (fn))
+			  error_at (gimple_location (stmt),
+				    "unsafe function call %qE within "
+				    "atomic transaction", fn);
+			else
+			  error_at (gimple_location (stmt),
+				    "unsafe indirect function call within "
+				    "atomic transaction");
+		      }
 		  }
 		else
 		  {
@@ -675,9 +682,16 @@  diagnose_tm_1 (gimple_stmt_iterator *gsi
 				"unsafe function call %qD within "
 				"%<transaction_safe%> function", fn);
 		    else
-		      error_at (gimple_location (stmt),
-				"unsafe function call %qE within "
-				"%<transaction_safe%> function", fn);
+		      {
+			if (!DECL_P (fn) || DECL_NAME (fn))
+			  error_at (gimple_location (stmt),
+				    "unsafe function call %qE within "
+				    "%<transaction_safe%> function", fn);
+			else
+			  error_at (gimple_location (stmt),
+				    "unsafe indirect function call within "
+				    "%<transaction_safe%> function");
+		      }
 		  }
 	      }
 	  }