https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61886
--- Comment #19 from rguenther at suse dot de <rguenther at suse dot de> --- On Mon, 6 Oct 2014, hubicka at ucw dot cz wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61886 > > --- Comment #11 from Jan Hubicka <hubicka at ucw dot cz> --- > Hi, > this patch implements the lowring. Each call with warn attribute triggers > code > in cgraphunit that inserts call to bulitin_warning/error that is output at > expansion time. > > Do we have way to define bulitin that is not user accessible? > > Also we do not have way to define LOOPING_CONST bulitin, so I am simply > forcing > the flag in cgraphunit.c that is somewhat ugly. But this also means that when attaching the attribute to pure/const functions which result becomes unused and thus the call gets DCEd will still emit the warning/error. Similar if the function gets inlined (formerly no warning/error). I think you need an alternate lowering for the first case at least, like passing through the return value. Not sure how to deal with the 2nd case. That said, I don't think this is the way to go to implement the attribute.