re PR middle-end/51696 ([trans-mem] unsafe indirect function call in struct not prope...
authorAldy Hernandez <aldyh@redhat.com>
Wed, 4 Jan 2012 14:32:54 +0000 (14:32 +0000)
committerAldy Hernandez <aldyh@gcc.gnu.org>
Wed, 4 Jan 2012 14:32:54 +0000 (14:32 +0000)
        PR middle-end/51696
        * trans-mem.c (diagnose_tm_1): Display indirect calls with no name
        correctly.

From-SVN: r182876

gcc/ChangeLog
gcc/testsuite/gcc.dg/tm/pr51696.c [new file with mode: 0644]
gcc/trans-mem.c

index 33caab17d6ade1ac0cd34a1fe7ee54043f5e523f..fc64456497162bd042a25363de1833fee7a51ef8 100644 (file)
@@ -1,3 +1,9 @@
+2012-01-04  Aldy Hernandez  <aldyh@redhat.com>
+
+       PR middle-end/51696
+       * trans-mem.c (diagnose_tm_1): Display indirect calls with no name
+       correctly.
+
 2012-01-04  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/51750
diff --git a/gcc/testsuite/gcc.dg/tm/pr51696.c b/gcc/testsuite/gcc.dg/tm/pr51696.c
new file mode 100644 (file)
index 0000000..02ee3f5
--- /dev/null
@@ -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 c0a8b8c8ac42f9fb726f7aa6b7ea4af4d6a47e53..750f3a186241a355f04684705a57a4d8af954edd 100644 (file)
@@ -664,9 +664,16 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi, bool *handled_ops_p,
                                "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, bool *handled_ops_p,
                                "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");
+                     }
                  }
              }
          }