From dee07a6a9fa17ae15dc34e1f31310a7c2dbfc30f Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 24 Dec 2016 04:34:33 +0000 Subject: [PATCH] Enable -Wunreachable-code and fix duplicate warning flags llvm-svn: 290486 --- libcxx/test/libcxx/compiler.py | 13 +++++-------- libcxx/test/libcxx/test/config.py | 2 ++ .../std/thread/futures/futures.async/async.pass.cpp | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libcxx/test/libcxx/compiler.py b/libcxx/test/libcxx/compiler.py index de716eccdd61..8585f44ed35f 100644 --- a/libcxx/test/libcxx/compiler.py +++ b/libcxx/test/libcxx/compiler.py @@ -147,9 +147,6 @@ class CXXCompiler(object): cmd += flags return cmd - def _getWarningFlags(self): - return self.warning_flags if self.use_warnings else [] - def preprocessCmd(self, source_files, out=None, flags=[]): return self._basicCmd(source_files, out, flags=flags, mode=self.CM_PreProcess, @@ -277,22 +274,21 @@ class CXXCompiler(object): another error is triggered during compilation. """ assert isinstance(flag, str) + assert flag.startswith('-W') if not flag.startswith('-Wno-'): - if self.hasCompileFlag(flag): - self.warning_flags += [flag] - return True - return False + return self.hasCompileFlag(flag) flags = ['-Werror', flag] old_use_warnings = self.use_warnings self.useWarnings(False) cmd = self.compileCmd('-', os.devnull, flags) - self.useWarnings(True) + self.useWarnings(old_use_warnings) # Remove '-v' because it will cause the command line invocation # to be printed as part of the error output. # TODO(EricWF): Are there other flags we need to worry about? if '-v' in cmd: cmd.remove('-v') out, err, rc = lit.util.executeCommand(cmd, input='#error\n') + assert rc != 0 if flag in err: return False @@ -300,6 +296,7 @@ class CXXCompiler(object): def addWarningFlagIfSupported(self, flag): if self.hasWarningFlag(flag): + assert flag not in self.warning_flags self.warning_flags += [flag] return True return False diff --git a/libcxx/test/libcxx/test/config.py b/libcxx/test/libcxx/test/config.py index 250c2f1a6080..c2408683cfe2 100644 --- a/libcxx/test/libcxx/test/config.py +++ b/libcxx/test/libcxx/test/config.py @@ -646,6 +646,7 @@ class Configuration(object): enable_warnings = self.get_lit_bool('enable_warnings', default_enable_warnings) if enable_warnings: + self.cxx.useWarnings(True) self.cxx.warning_flags += [ '-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER', '-Wall', '-Wextra', '-Werror' @@ -662,6 +663,7 @@ class Configuration(object): self.cxx.addWarningFlagIfSupported('-Wsign-compare') self.cxx.addWarningFlagIfSupported('-Wunused-variable') self.cxx.addWarningFlagIfSupported('-Wunused-parameter') + self.cxx.addWarningFlagIfSupported('-Wunreachable-code') # FIXME: Enable the two warnings below. self.cxx.addWarningFlagIfSupported('-Wno-conversion') self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef') diff --git a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp index 0f5ee05e9a08..9adebb285111 100644 --- a/libcxx/test/std/thread/futures/futures.async/async.pass.cpp +++ b/libcxx/test/std/thread/futures/futures.async/async.pass.cpp @@ -72,7 +72,8 @@ std::unique_ptr f4(std::unique_ptr&& p) void f5(int j) { std::this_thread::sleep_for(ms(200)); - TEST_THROW(j); ((void)j); + ((void)j); + TEST_THROW(j); } template