dvidelabs/flatcc

Misleading indentation errors on gcc 11.x

gmolina-a2e opened this issue ยท 12 comments

Had to suppress that warning to be able to compile.

This does the trick:
if (NOT (GCC_VERSION VERSION_LESS 11.0))
# Disable warning on misleading indentation it become more aggressive in 11.0
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-misleading-indentation")
endif()

Where do you get indentation errors? If it it is localized, perhaps we can fix at source level, otherwise I'm happy to add you suggestion. I presume this is for the main CMake file.

If am not mistaken all errors are in this file: flatbuffers_common_builder.h I tried an auto formatter (clang-format) with little success. And yeah this is for the main CMake file.

OK, my patience with GCC warnings is limited so I'll disable.

Should be fixed on master, please check.
Wonder why this isn't part of pedantic that should already have been disabled on recent GCC.

It is, thanks. I will close this issue.

I see, pedantic is still on for GCC, next time I'm going to remove pedantic for GCC.

amery commented

as the problem is still present, what about including #pragma GCC diagnostic ignored "-Wmisleading-indentation" on the generated files?

@amery There is distinction between compiling the flatcc tool chain and the runtime. Notably the runtime (library and generated) can be compiled by whatever tool chain the user prefers. I guess this topic only covers the tool chain.

There is a hook for dealing with runtime warnings in the portable library. This is mostly for generic issues that prevent smooth cross platform behaviour and are therefore always enabled. Others should be dealt with in the users tool chain.

The current situation is a bit special because the warning is actually useful in the general case, but specifically for flatcc generated code, it is not helpful. Therefore we cannot or should not inject the warning at the portable layer because the portable library is not flatcc specific.

I have not fully investigated, but I think can conditionally disable the the warning in pdiagnostic.h which is included in all generated files. Then set a flag in flatcc specific include files to enable the warning in this context.

Would you be willing to look into this?

Here the warning can be added in either pwarnings or probably better pdiagnostic.h, guarded by a PDIAGNOSTIC flag:

https://github.com/dvidelabs/flatcc/blob/master/include/flatcc/portable/pwarnings.h
https://github.com/dvidelabs/flatcc/blob/master/include/flatcc/portable/pdiagnostic.h
https://github.com/dvidelabs/flatcc/blob/master/include/flatcc/portable/pdiagnostic_push.h (and pop)

I think the PDIAGNOSTIC enabled warning could then be enabled with a define in
https://github.com/dvidelabs/flatcc/blob/master/include/flatcc/flatcc_flatbuffers.h
or
https://github.com/dvidelabs/flatcc/blob/master/include/flatcc/flatcc_rtconfig.h