diff mbox

[RFC,for,2.10,33/35] configure: clang does not support -Wexpansion-to-defined

Message ID 20170724182751.18261-34-f4bug@amsat.org
State New
Headers show

Commit Message

Philippe Mathieu-Daudé July 24, 2017, 6:27 p.m. UTC
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 configure | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini July 24, 2017, 8:08 p.m. UTC | #1
On 24/07/2017 20:27, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  configure | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index 6b52e19ee3..48295aa1e6 100755
> --- a/configure
> +++ b/configure
> @@ -1582,8 +1582,12 @@ gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
>  gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
>  gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
>  gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
> -gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
> +gcc_flags="-Wno-initializer-overrides $gcc_flags"
>  gcc_flags="-Wno-string-plus-int $gcc_flags"
> +# clang does not support -Wexpansion-to-defined
> +if ! echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
> +    gcc_flags="-Wexpansion-to-defined $gcc_flags"
> +fi
>  # Note that we do not add -Werror to gcc_flags here, because that would
>  # enable it for all configure tests. If a configure test failed due
>  # to -Werror this would just silently disable some features,

Clang 3.9 does.

Paolo
Peter Maydell July 24, 2017, 9:22 p.m. UTC | #2
On 24 July 2017 at 19:27, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  configure | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 6b52e19ee3..48295aa1e6 100755
> --- a/configure
> +++ b/configure
> @@ -1582,8 +1582,12 @@ gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
>  gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
>  gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
>  gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
> -gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
> +gcc_flags="-Wno-initializer-overrides $gcc_flags"
>  gcc_flags="-Wno-string-plus-int $gcc_flags"
> +# clang does not support -Wexpansion-to-defined
> +if ! echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
> +    gcc_flags="-Wexpansion-to-defined $gcc_flags"
> +fi

We already have a mechanism for testing that the warning
flags we pass here are actually supported by the compiler
(the cc_has_warning_flag() function, which we run on
every flag in $gcc_flags). Why does -Wexpansion-to-defined
need special casing?

thanks
-- PMM
Philippe Mathieu-Daudé July 24, 2017, 9:55 p.m. UTC | #3
On 07/24/2017 06:22 PM, Peter Maydell wrote:
> On 24 July 2017 at 19:27, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>   configure | 6 +++++-
>>   1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/configure b/configure
>> index 6b52e19ee3..48295aa1e6 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1582,8 +1582,12 @@ gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
>>   gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
>>   gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
>>   gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
>> -gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
>> +gcc_flags="-Wno-initializer-overrides $gcc_flags"
>>   gcc_flags="-Wno-string-plus-int $gcc_flags"
>> +# clang does not support -Wexpansion-to-defined
>> +if ! echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
>> +    gcc_flags="-Wexpansion-to-defined $gcc_flags"
>> +fi
> 
> We already have a mechanism for testing that the warning
> flags we pass here are actually supported by the compiler
> (the cc_has_warning_flag() function, which we run on
> every flag in $gcc_flags). Why does -Wexpansion-to-defined
> need special casing?

Yeah no idea, it works with clang 3.9 but not 5.0, I didn't investigate 
further. I prefixed this patch 'RFC' to not consider it but provide it 
if someone wanted to reproduce the analysis. Maybe I should prefix it 
'XXX' next time or 'NOT FOR MERGE'.

Regards,

Phil.
diff mbox

Patch

diff --git a/configure b/configure
index 6b52e19ee3..48295aa1e6 100755
--- a/configure
+++ b/configure
@@ -1582,8 +1582,12 @@  gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
 gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags"
 gcc_flags="-Wno-missing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"
 gcc_flags="-Wendif-labels -Wno-shift-negative-value $gcc_flags"
-gcc_flags="-Wno-initializer-overrides -Wexpansion-to-defined $gcc_flags"
+gcc_flags="-Wno-initializer-overrides $gcc_flags"
 gcc_flags="-Wno-string-plus-int $gcc_flags"
+# clang does not support -Wexpansion-to-defined
+if ! echo | $cc -dM -E - | grep __clang__ > /dev/null 2>&1 ; then
+    gcc_flags="-Wexpansion-to-defined $gcc_flags"
+fi
 # Note that we do not add -Werror to gcc_flags here, because that would
 # enable it for all configure tests. If a configure test failed due
 # to -Werror this would just silently disable some features,