This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][C++] Fix PR60761, diagnostics in clones


This fixes PR60761 by dumping decl context of function clones
as origin with <clone> appended instead of <built-in> that now
appears after we (compared to 4.8) clear DECL_LANG_SPECIFIC.

Thus for the testcase in PR60761 we now print

t.ii: In function 'void foo(int) <clone>':
t.ii:14:13: warning: iteration 3u invokes undefined behavior 
[-Waggressive-loop-optimizations]
     z[i] = i;
             ^
t.ii:13:3: note: containing loop
   for (int i = 0; i < s; i++)
   ^
t.ii:14:8: warning: array subscript is above array bounds [-Warray-bounds]
     z[i] = i;
        ^

instead of

t.ii: In function ʽ<built-in>ʼ:
t.ii:14:13: warning: iteration 3u invokes undefined behavior 
[-Waggressive-loop-optimizations]
     z[i] = i;
             ^
t.ii:13:3: note: containing loop
   for (int i = 0; i < s; i++)
   ^
t.ii:14:8: warning: array subscript is above array bounds [-Warray-bounds]
     z[i] = i;
        ^

or with 4.8

t.ii: In function ʽvoid _Z3fooi.constprop.0()ʼ:
t.ii:14:8: warning: array subscript is above array bounds [-Warray-bounds]
     z[i] = i;
        ^

IMHO an improvement over both variants.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Honza - does ->former_clone_of apply recursively or do I have to
loop to find the "ultimate" clone-of?  Jason, is <clone> good
or shall I use sth else (do we annotate in-charge vs. not in-charge
constructors specially for example?).

Ok?

Thanks,
Richard.

2014-04-08  Richard Biener  <rguenther@suse.de>

	cp/
	* error.c: Include cgraph.h
	(dump_decl): Print function clones as their origin plus <clone>
	appended instead of just <built-in>.

Index: gcc/cp/error.c
===================================================================
*** gcc/cp/error.c	(revision 209210)
--- gcc/cp/error.c	(working copy)
*************** along with GCC; see the file COPYING3.
*** 34,39 ****
--- 34,40 ----
  #include "pointer-set.h"
  #include "c-family/c-objc.h"
  #include "ubsan.h"
+ #include "cgraph.h"
  
  #include <new>                    // For placement-new.
  
*************** dump_decl (cxx_pretty_printer *pp, tree
*** 1145,1151 ****
  
      case FUNCTION_DECL:
        if (! DECL_LANG_SPECIFIC (t))
! 	pp_string (pp, M_("<built-in>"));
        else if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
  	dump_global_iord (pp, t);
        else
--- 1146,1162 ----
  
      case FUNCTION_DECL:
        if (! DECL_LANG_SPECIFIC (t))
! 	{
! 	  cgraph_node *node;
! 	  if ((node = cgraph_get_node (t))
! 	      && node->former_clone_of)
! 	    {
! 	      dump_decl (pp, node->former_clone_of, flags);
! 	      pp_string (pp, M_(" <clone>"));
! 	    }
! 	  else
! 	    pp_string (pp, M_("<built-in>"));
! 	}
        else if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
  	dump_global_iord (pp, t);
        else

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]