Re: [PATCH] Add -Wexternal-function-has-definition

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

 



n Tue, Nov 12, 2019 at 04:13:58PM +0000, John Levon wrote:
> Some older codebases hit this warning all the time, so it's useful
> to be able to disable it.

Thank you.
 
> @@ -2769,10 +2769,12 @@ static struct token *parse_function_body(struct token *token, struct symbol *dec
> -	if (decl->ctype.modifiers & MOD_EXTERN) {
> -		if (!(decl->ctype.modifiers & MOD_INLINE))
> -			warning(decl->pos, "function '%s' with external linkage has definition", show_ident(decl->ident));
> +	if (Wexternal_function_has_definition &&
> +		decl->ctype.modifiers & MOD_EXTERN &&
> +		!(decl->ctype.modifiers & MOD_INLINE)) {
> +		warning(decl->pos, "function '%s' with external linkage has definition", show_ident(decl->ident));

I've slightly changed this part to have the test of the W flag
next to the warning itself, which I prefer:
-	if (decl->ctype.modifiers & MOD_EXTERN) {
-		if (!(decl->ctype.modifiers & MOD_INLINE))
+	if ((decl->ctype.modifiers & (MOD_EXTERN|MOD_INLINE)) == MOD_EXTERN) {
+		if (Wexternal_function_has_definition)


Best regards,
-- Luc



[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