PR47747: Fix error messages for calls to unsafe virtual functions.
authorTorvald Riegel <triegel@redhat.com>
Mon, 21 Nov 2011 22:29:31 +0000 (22:29 +0000)
committerTorvald Riegel <torvald@gcc.gnu.org>
Mon, 21 Nov 2011 22:29:31 +0000 (22:29 +0000)
gcc/
* trans-mem.c (diagnose_tm_1): Print an expression instead of a
declaration in error messages for indirect calls.

testsuite/
g++.dg/tm/pr47747.C: New test.

From-SVN: r181602

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tm/pr47747.C [new file with mode: 0644]
gcc/trans-mem.c

index d45424f8637b8de7500db5f05ef93bc523b15a8f..8c776dc3c730522a1a47a17b11f0a58b9a9321ed 100644 (file)
@@ -1,3 +1,8 @@
+2011-11-21  Torvald Riegel  <triegel@redhat.com>
+
+       * trans-mem.c (diagnose_tm_1): Print an expression instead of a
+       declaration in error messages for indirect calls.
+
 2011-11-21  David S. Miller  <davem@davemloft.net>
 
        * config/sparc/sparc.c (sparc_regmode_natural_size): New function
index c661df870036b8288935529dcf718824096ac802..0f3216e6da2adc21ce2cd52f9f8bf5d76d5b68c2 100644 (file)
@@ -1,3 +1,7 @@
+2011-11-21  Torvald Riegel  <triegel@redhat.com>
+
+       * g++.dg/tm/pr47747.C: New test.
+
 2011-11-21  Torvald Riegel  <triegel@redhat.com>
 
        * g++.dg/tm/template-2.C: New test.
diff --git a/gcc/testsuite/g++.dg/tm/pr47747.C b/gcc/testsuite/g++.dg/tm/pr47747.C
new file mode 100644 (file)
index 0000000..3b50904
--- /dev/null
@@ -0,0 +1,21 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O" }
+
+class InputStream
+{
+        public:
+//        __attribute__((transaction_safe))
+        virtual unsigned int readUint32 () = 0;
+};
+
+class Building
+{
+        public:
+        __attribute__((transaction_safe))
+        Building (InputStream *stream);
+};
+
+Building::Building (InputStream *stream)
+{
+        stream->readUint32 (); /* { dg-error "InputStream::readUint32" } */
+}
index 3c0bd600943f33ed57bee293c22ed7a6df69f674..347183b15689b8e3b49e7cb4224cd320dff91639 100644 (file)
@@ -659,13 +659,27 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi, bool *handled_ops_p,
                if (TREE_CODE (fn) == ADDR_EXPR)
                  fn = TREE_OPERAND (fn, 0);
                if (d->block_flags & DIAG_TM_SAFE)
-                 error_at (gimple_location (stmt),
-                           "unsafe function call %qD within "
-                           "atomic transaction", fn);
+                 {
+                   if (direct_call_p)
+                     error_at (gimple_location (stmt),
+                               "unsafe function call %qD within "
+                               "atomic transaction", fn);
+                   else
+                     error_at (gimple_location (stmt),
+                               "unsafe function call %qE within "
+                               "atomic transaction", fn);
+                 }
                else
-                 error_at (gimple_location (stmt),
-                           "unsafe function call %qD within "
-                           "%<transaction_safe%> function", fn);
+                 {
+                   if (direct_call_p)
+                     error_at (gimple_location (stmt),
+                               "unsafe function call %qD within "
+                               "%<transaction_safe%> function", fn);
+                   else
+                     error_at (gimple_location (stmt),
+                               "unsafe function call %qE within "
+                               "%<transaction_safe%> function", fn);
+                 }
              }
          }
       }