On 04/11/2018 10:02 AM, Jakub Jelinek wrote: > On Wed, Apr 11, 2018 at 09:48:05AM +0200, Andreas Krebbel wrote: >> c-c++-common/attr-nonstring-3.c fails on IBM Z. The reason appears to be >> that we provide builtin implementations for strcpy and stpcpy. The >> warnings currently will only be emitted when expanding these as normal >> calls. >> >> Bootstrapped and regression tested on x86_64 and s390x. >> >> Ok? >> >> gcc/ChangeLog: >> >> 2018-04-11 Andreas Krebbel <kreb...@linux.vnet.ibm.com> >> >> * builtins.c (expand_builtin_strcpy): Invoke >> maybe_warn_nonstring_arg. >> (expand_builtin_stpcpy): Likewise. > > Don't you then warn twice if builtin implementations for strcpy and stpcpy > aren't available or can't be used, once here and once in calls.c?
Looks like this could happen if the expander is present but rejects expansion. I basically copied this from the strcmp builtin which looks like possibly running into the same problem: /* Check to see if the argument was declared attribute nonstring and if so, issue a warning since at this point it's not known to be nul-terminated. */ tree fndecl = get_callee_fndecl (exp); maybe_warn_nonstring_arg (fndecl, exp); if (result) { /* Return the value in the proper mode for this function. */ machine_mode mode = TYPE_MODE (TREE_TYPE (exp)); if (GET_MODE (result) == mode) return result; if (target == 0) return convert_to_mode (mode, result, 0); convert_move (target, result, 0); return target; } /* Expand the library call ourselves using a stabilized argument list to avoid re-evaluating the function's arguments twice. */ tree fn = build_call_nofold_loc (EXPR_LOCATION (exp), fndecl, 2, arg1, arg2); gcc_assert (TREE_CODE (fn) == CALL_EXPR); CALL_EXPR_TAILCALL (fn) = CALL_EXPR_TAILCALL (exp); return expand_call (fn, target, target == const0_rtx); -Andreas-