t-nissieの日記: 【電脳】なにかと話題のgcc-6のifのインデントのミスを警告してくれる-Wmisleading-indentationを試してみる
日記 by
t-nissie
$ gcc --version
gcc (GCC) 6.0.0 20151115 (experimental)
$ cat check_age.c
/* check_age.c */
void drink(), smoke();
void check_age(int age)
{
if (20<=age)
drink();
smoke();
}
$ gcc -Wmisleading-indentation -c check_age.c
check_age.c: 関数 ‘check_age’ 内:
check_age.c:7:5: 警告: statement is indented as if it were guarded by... [-Wmisleading-indentation]
smoke();
^~~~~
check_age.c:5:3: 備考: ...this ‘if’ clause, but it is not
if (20<=age)
^~
$
まあ、前にも書きましたが、Fortranなら
if (20<=age) call drink()
か
if (20<=age) then
call drink()
call smoke()
end if
としか書けないのですがね。
【電脳】なにかと話題のgcc-6のifのインデントのミスを警告してくれる-Wmisleading-indentationを試してみる More ログイン