On 05/10/2018 17:25, Richard Henderson wrote:
> On 10/5/18 4:10 AM, Peter Maydell wrote:
>> On 5 October 2018 at 01:28, Laurent Vivier <[email protected]> wrote:
>>> I have the following error when building on Fedora 28 and gcc (GCC)
>>> 8.1.1 20180712 (Red Hat 8.1.1-5)
>>>
>>> CC aarch64_be-linux-user/target/arm/arm-semi.o
>>> .../target/arm/arm-semi.c: In function ‘do_arm_semihosting’:
>>> .../target/arm/arm-semi.c:270:1: error: unknown option after ‘#pragma
>>> GCC diagnostic’ kind [-Werror=pragmas]
>>>
>>> Perhaps you should use a "#if defined(__clang__)" to apply your fix only
>>> to clang?
>>
>> I did test on gcc, but not that version. The point of the
>> _Pragma("GCC diagnostic ignored \"-Wpragmas\"");
>> line is to suppress that error (which it does on my gcc 5)
>> so I don't know why your gcc is complaining :-(
>
> I suppose you could try -Wunknown-pragmas.
> But from reading the manual it shouldn't make a difference.
> OTOH, what you wrote should have worked...
Could it be a bug in _Pragma()?
If I use "#pragma" for the file, it works:
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -474,10 +474,10 @@ static inline int access_ok(int type, abi_ulong addr,
abi_ulong size)
* an unknown warning type from older compilers that don't know about
* -Waddress-of-packed-member.
*/
+#pragma GCC diagnostic ignored "-Wpragmas"
#define __put_user_e(x, hptr, e) \
do { \
_Pragma("GCC diagnostic push"); \
- _Pragma("GCC diagnostic ignored \"-Wpragmas\""); \
_Pragma("GCC diagnostic ignored \"-Waddress-of-packed-member\""); \
(__builtin_choose_expr(sizeof(*(hptr)) == 1, stb_p, \
__builtin_choose_expr(sizeof(*(hptr)) == 2, stw_##e##_p, \
@@ -490,7 +490,6 @@ static inline int access_ok(int type, abi_ulong addr,
abi_ulong size)
#define __get_user_e(x, hptr, e) \
do { \
_Pragma("GCC diagnostic push"); \
- _Pragma("GCC diagnostic ignored \"-Wpragmas\""); \
_Pragma("GCC diagnostic ignored \"-Waddress-of-packed-member\""); \
((x) = (typeof(*hptr))( \
__builtin_choose_expr(sizeof(*(hptr)) == 1, ldub_p, \