summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authortorvald <torvald@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-21 22:29:31 +0000
committertorvald <torvald@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-21 22:29:31 +0000
commit2d3bf658915afc664d9c1f7ef06000a945eeb2bf (patch)
tree34a48a93c32d86a3671f6aa53cd162dbd27c0c21 /gcc
parente1beed70f0a662b3c5162bb34b7f3f032f339f81 (diff)
downloadgcc-2d3bf658915afc664d9c1f7ef06000a945eeb2bf.tar.gz
PR47747: Fix error messages for calls to unsafe virtual functions.
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181602 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/tm/pr47747.C21
-rw-r--r--gcc/trans-mem.c26
4 files changed, 50 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d45424f8637..8c776dc3c73 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c661df87003..0f3216e6da2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
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.
2011-11-21 Jakub Jelinek <jakub@redhat.com>
diff --git a/gcc/testsuite/g++.dg/tm/pr47747.C b/gcc/testsuite/g++.dg/tm/pr47747.C
new file mode 100644
index 00000000000..3b50904b5d9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tm/pr47747.C
@@ -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" } */
+}
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index 3c0bd600943..347183b1568 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -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);
+ }
}
}
}