Re: [RFC/PATCH] git-compat-util.h: Don't define NORETURN under __clang__

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

 



Ævar Arnfjörð Bjarmason venit, vidit, dixit 03.08.2010 15:08:

> clang version 1.0 on Debian testing x86_64 defines __GNUC__, but barfs
> on `void __attribute__((__noreturn__))'. E.g.:
> 
>     usage.c:56:1: error: function declared 'noreturn' should not return [-Winvalid-noreturn]
>     }
>     ^
>     1 diagnostic generated.
>     make: *** [usage.o] Error 1

It doesn't mean that it's not accepting __noreturn__, it means it was
not smart enough to check that the function do not return.

In my git, usage.c:56: leads me to this function:

void usagef(const char *err, ...)
{
	va_list params;

	va_start(params, err);
	usage_routine(err, params);
	va_end(params);
}

The absence of return comes from usage_routine, which is a pointer to
function, and it seems your version of clang doesn't handle
__noreturn__ pointers to functions properly.

On my box:

git$ make -B CC=clang V=yes usage.o                                                                                                        
clang -o usage.o -c   -g -Wall -Werror -I.  -DHAVE_PATHS_H -DSHA1_HEADER='<openssl/sha.h>'  -DNO_STRLCPY -DNO_MKSTEMPS  usage.c
git$ clang --version
clang version 1.1 (branches/release_27)
Target: i386-pc-linux-gnu
Thread model: posix

so, more recent clang do not seem to have this issue.

> diff --git a/git-compat-util.h b/git-compat-util.h
> index 02a73ee..c651cb7 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -183,7 +183,10 @@ extern char *gitbasename(char *);
>  #define is_dir_sep(c) ((c) == '/')
>  #endif
>  
> -#ifdef __GNUC__
> +#ifdef __clang__
> +#define NORETURN
> +#define NORETURN_PTR __attribute__((__noreturn__))
> +#elif __GNUC__

If you go for something like this, you should check the version of
clang, and special-case only version < 1.1.

But I'm not sure special-casing old version of a young compiler really
makes sense. We're only talking about warnings here, so I'd say you
should either upgrade clang or remove -Werror from your CFLAGS.

(other than that, it's cool to see someone testing another
compiler ;-) )

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]