On 23/04/2020 14:47, Đoàn Trần Công Danh wrote: > * alloca: somewhere later in the code, we indirectly include alloca.h > which will define alloca again, include it prior to define alloca in > order to not define it against. > > * Copy all attributes from the header to source file, and move the > attributes prior to function name. cgcc is very picky on the position > of attribute. This patch is no longer needed (iff you use a bleeding edge version of sparse), since this was fixed in commit 172f6a98 ("let function definition inherit prototype attributes", 2019-11-19). $ git describe 172f6a98 v0.6.1-37-g172f6a98 $ Ah, so this fix is not in any released version of sparse (v0.6.1 is the current release - I always build/run the tip of the 'master' branch from the sparse git repo). I starred at this warning for years (on cygwin, I don't build with NO_REGEX on Linux), but I didn't send a patch for it because it was a sparse fault. ATB, Ramsay Jones > > Signed-off-by: Đoàn Trần Công Danh <congdanhqx@xxxxxxxxx> > --- > compat/regex/regex.c | 1 + > compat/regex/regex_internal.c | 2 +- > compat/regex/regex_internal.h | 5 ++--- > 3 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/compat/regex/regex.c b/compat/regex/regex.c > index f3e03a9eab..4bef75a716 100644 > --- a/compat/regex/regex.c > +++ b/compat/regex/regex.c > @@ -62,6 +62,7 @@ > #include <stdint.h> > > #ifdef GAWK > +#include <alloca.h> > #undef alloca > #define alloca alloca_is_bad_you_should_never_use_it > #endif > diff --git a/compat/regex/regex_internal.c b/compat/regex/regex_internal.c > index ec51cf3446..58504f795b 100644 > --- a/compat/regex/regex_internal.c > +++ b/compat/regex/regex_internal.c > @@ -921,7 +921,7 @@ re_string_destruct (re_string_t *pstr) > /* Return the context at IDX in INPUT. */ > > static unsigned int > -internal_function > +internal_function __attribute ((pure)) > re_string_context_at (const re_string_t *input, int idx, int eflags) > { > int c; > diff --git a/compat/regex/regex_internal.h b/compat/regex/regex_internal.h > index 3ee8aae59d..c61a1e4971 100644 > --- a/compat/regex/regex_internal.h > +++ b/compat/regex/regex_internal.h > @@ -430,9 +430,8 @@ static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr) > # endif /* RE_ENABLE_I18N */ > static void build_upper_buffer (re_string_t *pstr) internal_function; > static void re_string_translate_buffer (re_string_t *pstr) internal_function; > -static unsigned int re_string_context_at (const re_string_t *input, int idx, > - int eflags) > - internal_function __attribute ((pure)); > +static internal_function __attribute ((pure)) > +unsigned int re_string_context_at (const re_string_t *input, int idx, int eflags); > #endif > #define re_string_peek_byte(pstr, offset) \ > ((pstr)->mbs[(pstr)->cur_idx + offset]) >