Bug 1406618 - Enable gcc -Wduplicated-cond warnings. r=glandium

Warn about duplicated conditions in if-else-if chains, which are unreachable code and likely copy/paste bugs. The -Wduplicated-cond flag is available in gcc 6 and later.

  int example(int a)
  {
    if (a == 0)
      a = 42;
    else if (a == 0) // -Wduplicated-cond warning!
      a = 43;
    return a;
  }

MozReview-Commit-ID: F9hqxMCct74

--HG--
extra : rebase_source : 71168f79ce8f03f650167cdedbbd2e5802846eab
This commit is contained in:
Chris Peterson 2017-10-05 23:14:02 -07:00
Родитель fd26fb0032
Коммит 925214d9af
1 изменённых файлов: 3 добавлений и 0 удалений

Просмотреть файл

@ -65,6 +65,9 @@ check_and_add_gcc_warning('-Wc++1z-compat', cxx_compiler)
# catches possible misuse of the comma operator
check_and_add_gcc_warning('-Wcomma', cxx_compiler)
# catches duplicated conditions in if-else-if chains
check_and_add_gcc_warning('-Wduplicated-cond')
# catches unintentional switch case fallthroughs
check_and_add_gcc_warning('-Wimplicit-fallthrough', cxx_compiler)