Re: [PATCH 5/5] allow omitted function attribute in definition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 20/11/2019 00:02, Luc Van Oostenryck wrote:
> It's common to declare a function with the attribute
> 'pure' or 'noreturn' and to omit the attribute in the
> function definition.
> 
> It make some sense since the information convoyed by

s/convoyed/conveyed/

> these attribute are destinated to the function users

s/attribute/attributes/
s/destinated to/destined for/

> not the function itself.
> 
> Silence the warnings emitted when the attributes are
> omited by masking the corresponding modifier bits

s/omited/omitted/

> when checking the type compatibility between a
> function definition and its declarations.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  evaluate.c                              | 4 +++-
>  validation/function-attribute-omitted.c | 1 -
>  validation/function-redecl2.c           | 3 ---
>  3 files changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/evaluate.c b/evaluate.c
> index 863750fab..4e1762eff 100644
> --- a/evaluate.c
> +++ b/evaluate.c
> @@ -3371,6 +3371,7 @@ void check_duplicates(struct symbol *sym)
>  	int initialized = sym->initializer != NULL;
>  
>  	while ((next = next->same_symbol) != NULL) {
> +		unsigned long fmods;
>  		const char *typediff;
>  		evaluate_symbol(next);
>  		if (initialized && next->initializer) {
> @@ -3381,7 +3382,8 @@ void check_duplicates(struct symbol *sym)
>  			initialized = 0;
>  		}
>  		declared++;
> -		typediff = type_difference(&sym->ctype, &next->ctype, 0, 0);
> +		fmods = next->ctype.modifiers & MOD_FUN_ATTR;
> +		typediff = type_difference(&sym->ctype, &next->ctype, fmods, 0);
>  		if (typediff) {
>  			sparse_error(sym->pos, "symbol '%s' redeclared with different type (originally declared at %s:%d) - %s",
>  				show_ident(sym->ident),
> diff --git a/validation/function-attribute-omitted.c b/validation/function-attribute-omitted.c
> index 43b301d8f..c5eb50d31 100644
> --- a/validation/function-attribute-omitted.c
> +++ b/validation/function-attribute-omitted.c
> @@ -10,5 +10,4 @@ void		n(void) { while (1) ; }
>  
>  /*
>   * check-name: function-attribute-omitted
> - * check-known-to-fail

yay!  \O/

Thanks! (That's all for tonight!)

ATB,
Ramsay Jones

>   */
> diff --git a/validation/function-redecl2.c b/validation/function-redecl2.c
> index 3435aa00c..ef396137a 100644
> --- a/validation/function-redecl2.c
> +++ b/validation/function-redecl2.c
> @@ -25,7 +25,4 @@ void func2(int a)
>  
>  /*
>   * check-name: function-redecl2
> - *
> - * check-known-to-fail
> - *
>   */
> 



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux