diff mbox series

[3/3] tools/libxl: disable clang indentation check for the disk parser

Message ID 20200505092454.9161-4-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show
Series build: fixes for clang 10 | expand

Commit Message

Roger Pau Monné May 5, 2020, 9:24 a.m. UTC
Clang 10 complains with:

13: error: misleading indentation; statement is not part of the previous 'if'
      [-Werror,-Wmisleading-indentation]
            if ( ! yyg->yy_state_buf )
            ^
libxlu_disk_l.c:1259:9: note: previous statement is here
        if ( ! yyg->yy_state_buf )
        ^

Due to the missing braces in single line statements and the wrong
indentation. Fix this by disabling the warning for that specific file.
I haven't found a way to force flex to add braces around single line
statements in conditional blocks.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Please re-generate libxlu_disk_l.c before committing.
---
 tools/libxl/libxlu_disk_l.l | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Wei Liu May 6, 2020, 1:07 p.m. UTC | #1
On Tue, May 05, 2020 at 11:24:54AM +0200, Roger Pau Monne wrote:
> Clang 10 complains with:
> 
> 13: error: misleading indentation; statement is not part of the previous 'if'
>       [-Werror,-Wmisleading-indentation]
>             if ( ! yyg->yy_state_buf )
>             ^
> libxlu_disk_l.c:1259:9: note: previous statement is here
>         if ( ! yyg->yy_state_buf )
>         ^
> 
> Due to the missing braces in single line statements and the wrong
> indentation. Fix this by disabling the warning for that specific file.
> I haven't found a way to force flex to add braces around single line
> statements in conditional blocks.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Acked-by: Wei Liu <wl@xen.org>
diff mbox series

Patch

diff --git a/tools/libxl/libxlu_disk_l.l b/tools/libxl/libxlu_disk_l.l
index 97039a2800..7a46f4a30c 100644
--- a/tools/libxl/libxlu_disk_l.l
+++ b/tools/libxl/libxlu_disk_l.l
@@ -36,6 +36,17 @@ 
 
 #define YY_NO_INPUT
 
+/* The code generated by flex is missing braces in single line expressions and
+ * is not properly indented, which triggers the clang misleading-indentation
+ * check that has been made part of -Wall since clang 10. In order to safely
+ * disable it on clang versions that don't have the diagnostic implemented
+ * also disable the unknown option and pragma warning. */
+#ifdef __clang__
+# pragma clang diagnostic ignored "-Wunknown-pragmas"
+# pragma clang diagnostic ignored "-Wunknown-warning-option"
+# pragma clang diagnostic ignored "-Wmisleading-indentation"
+#endif
+
 /* Some versions of flex have a bug (Fedora bugzilla 612465) which causes
  * it to fail to declare these functions, which it defines.  So declare
  * them ourselves.  Hopefully we won't have to simultaneously support