Created attachment 40576 [details] reduced "HSAILValidatorBase.cpp" file I don't have any strong opinion, so I'm asking you to please check the following. Compiling <https://github.com/HSAFoundation/HSAIL-Tools>, commit 12220b0ddccd4559e979906bfd65fb49fcdd7854 with Ubuntu GCC 6.2.0-5ubuntu12, the build aborts: [...]/libHSAIL/HSAILValidatorBase.cpp: In member function 'virtual bool HSAIL_ASM::PropValidator::checkOperandKind(HSAIL_ASM::Inst, unsigned int, unsigned int*, unsigned int, bool) const': [...]/libHSAIL/HSAILValidatorBase.cpp:395:37: error: this 'if' clause does not guard... [-Werror=misleading-indentation] case OPERAND_VAL_FUNC: if (isCodeRef(opr, BRIG_KIND_DIRECTIVE_FUNCTION) || ^~ [...]/libHSAIL/HSAILValidatorBase.cpp:396:110: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' isCodeRef(opr, BRIG_KIND_DIRECTIVE_INDIRECT_FUNCTION)) return true; break; ^~~~~ cc1plus: all warnings being treated as errors I'm attaching a reduced "HSAILValidatorBase.cpp" file, showing the issue for both C and C++ compilation. Should the code be considered well-formed enough to not warn in this case?
Some notes: There are 7 cases in the reproducer, but it only warns for the 3rd case (lines 34-35). In each of the 7 cases in the reproducer, NEXT_STMT_LOC and BODY_LOC are on the same line: /* If NEXT_STMT_LOC and BODY_LOC are on the same line, consider the location of the guard. Case 3 matches the following conditional, and thus warns: if (guard_exploc.line < body_exploc.line) /* The guard is on a line before a line that contains both the body and the next stmt. */ return true; whereas the other cases match this conditional: else if (guard_exploc.line == body_exploc.line) { /* They're all on the same line. */ and try this heuristic: /* Heuristic: only warn if the guard is the first thing on its line. */ if (guard_vis_column == guard_line_first_nws) return true; ...which doesn't match, hence we don't warn for them.
Created attachment 40579 [details] Patch to tweak Wmisleading indentation This patch removes the "(guard_exploc.line == body_exploc.line)" condition from the: /* Heuristic: only warn if the guard is the first thing on its line. */ and hence silences the warning from the reproducer. It doesn't introduce any regressions in the testsuite (only tested briefly, though). [Would need ChangeLog, and testsuite coverage] Patrick, any thoughts?