From: Aldy Hernandez Date: Wed, 4 Jan 2012 14:32:54 +0000 (+0000) Subject: re PR middle-end/51696 ([trans-mem] unsafe indirect function call in struct not prope... X-Git-Tag: releases/gcc-4.7.0~1186 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3a54c4564436e79b70b8dd3b6651b7a2fbaea028;p=thirdparty%2Fgcc.git re PR middle-end/51696 ([trans-mem] unsafe indirect function call in struct not properly displayed) PR middle-end/51696 * trans-mem.c (diagnose_tm_1): Display indirect calls with no name correctly. From-SVN: r182876 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33caab17d6ad..fc6445649716 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-01-04 Aldy Hernandez + + PR middle-end/51696 + * trans-mem.c (diagnose_tm_1): Display indirect calls with no name + correctly. + 2012-01-04 Richard Guenther 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 index 000000000000..02ee3f517c00 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tm/pr51696.c @@ -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" } */ +} diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c index c0a8b8c8ac42..750f3a186241 100644 --- a/gcc/trans-mem.c +++ b/gcc/trans-mem.c @@ -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 " "% function", fn); else - error_at (gimple_location (stmt), - "unsafe function call %qE within " - "% function", fn); + { + if (!DECL_P (fn) || DECL_NAME (fn)) + error_at (gimple_location (stmt), + "unsafe function call %qE within " + "% function", fn); + else + error_at (gimple_location (stmt), + "unsafe indirect function call within " + "% function"); + } } } }