From patchwork Tue Jan 3 17:18:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: PR middle-end/51696: display indirect function calls properly for trans-mem Date: Tue, 03 Jan 2012 07:18:55 -0000 From: Aldy Hernandez X-Patchwork-Id: 134041 Message-Id: <4F03387F.308@redhat.com> To: gcc-patches , Richard Henderson On 01/03/12 11:04, Aldy Hernandez wrote: > For the following testcase, we display indirect calls as memory > addresses, which can confuse the user: > > struct list { > void (*compare)(); > } *listPtr; > static void (*compare)(); > __attribute__((transaction_safe)) > static void func () { > listPtr->compare(); > /* ^^^^^^^^^^^^^^^^^^^^^^^^^^ */ > /* error: unsafe function call ‘’.... */ > compare(); > } > > This happens because pp_c_tree_decl_identifier() dumps the memory > address when there is no DECL_NAME associated with the symbol. > > Instead of displaying something like in this particular error, > perhaps we can display "unsafe indirect function call...". > > OK? Whoops, wrong revision of the patch. Revised one here. PR middle-end/51696 * trans-mem.c (diagnose_tm_1): Display indirect calls with no name correctly. 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_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 " "% function", fn); else - error_at (gimple_location (stmt), - "unsafe function call %qE within " - "% function", fn); + { + if (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"); + } } } }