Author: ericwf Date: Fri Dec 23 22:34:33 2016 New Revision: 290486 URL: http://llvm.org/viewvc/llvm-project?rev=290486&view=rev Log: Enable -Wunreachable-code and fix duplicate warning flags
Modified: libcxx/trunk/test/libcxx/compiler.py libcxx/trunk/test/libcxx/test/config.py libcxx/trunk/test/std/thread/futures/futures.async/async.pass.cpp Modified: libcxx/trunk/test/libcxx/compiler.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/compiler.py?rev=290486&r1=290485&r2=290486&view=diff ============================================================================== --- libcxx/trunk/test/libcxx/compiler.py (original) +++ libcxx/trunk/test/libcxx/compiler.py Fri Dec 23 22:34:33 2016 @@ -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 Modified: libcxx/trunk/test/libcxx/test/config.py URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=290486&r1=290485&r2=290486&view=diff ============================================================================== --- libcxx/trunk/test/libcxx/test/config.py (original) +++ libcxx/trunk/test/libcxx/test/config.py Fri Dec 23 22:34:33 2016 @@ -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') Modified: libcxx/trunk/test/std/thread/futures/futures.async/async.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.async/async.pass.cpp?rev=290486&r1=290485&r2=290486&view=diff ============================================================================== --- libcxx/trunk/test/std/thread/futures/futures.async/async.pass.cpp (original) +++ libcxx/trunk/test/std/thread/futures/futures.async/async.pass.cpp Fri Dec 23 22:34:33 2016 @@ -72,7 +72,8 @@ std::unique_ptr<int> f4(std::unique_ptr< void f5(int j) { std::this_thread::sleep_for(ms(200)); - TEST_THROW(j); ((void)j); + ((void)j); + TEST_THROW(j); } template <class Ret, class CheckLamdba, class ...Args> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits