[libcxx-commits] [libcxx] fccc4af - [libc++] Re-enable warnings in the new format
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 21 10:01:25 PDT 2020
Author: Louis Dionne
Date: 2020-04-21T13:01:08-04:00
New Revision: fccc4af6588f1b2cf629e7dd1d1ab4617028b15b
URL: https://github.com/llvm/llvm-project/commit/fccc4af6588f1b2cf629e7dd1d1ab4617028b15b
DIFF: https://github.com/llvm/llvm-project/commit/fccc4af6588f1b2cf629e7dd1d1ab4617028b15b.diff
LOG: [libc++] Re-enable warnings in the new format
When the new libc++ test format was enabled, warnings were accidentally
dropped cause they were not part of the %{compile_flags} substitution.
This commit adds them back, however `-Werror` is only used for non-verify
tests (cause it doesn't make sense for verify tests).
This commit is a re-application of 20fd62438004, which was reverted in
5ec6fdb0580b because it broke the C++03 bot. This failure should have
been fixed in b4fb705e77aa.
Added:
Modified:
libcxx/test/std/containers/sequences/array/array.creation/to_array.fail.cpp
libcxx/utils/libcxx/test/config.py
libcxx/utils/libcxx/test/newformat.py
Removed:
################################################################################
diff --git a/libcxx/test/std/containers/sequences/array/array.creation/to_array.fail.cpp b/libcxx/test/std/containers/sequences/array/array.creation/to_array.fail.cpp
index 49ad6a61037f..39b92a0468dc 100644
--- a/libcxx/test/std/containers/sequences/array/array.creation/to_array.fail.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.creation/to_array.fail.cpp
@@ -14,6 +14,8 @@
#include "test_macros.h"
#include "MoveOnly.h"
+// expected-warning at array:* 0-1 {{suggest braces around initialization of subobject}}
+
int main(int, char**) {
{
char source[3][6] = {"hi", "world"};
diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py
index ce77ec8c71c9..6fbe2ba29fee 100644
--- a/libcxx/utils/libcxx/test/config.py
+++ b/libcxx/utils/libcxx/test/config.py
@@ -827,10 +827,12 @@ def configure_warnings(self):
enable_warnings = self.get_lit_bool('enable_warnings',
default_enable_warnings)
self.cxx.useWarnings(enable_warnings)
- self.cxx.warning_flags += [
- '-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER',
- '-Wall', '-Wextra', '-Werror'
- ]
+ self.cxx.warning_flags += ['-Wall', '-Wextra']
+ # On GCC, the libc++ headers cause errors due to throw() decorators
+ # on operator new clashing with those from the test suite, so we
+ # don't enable warnings in system headers on GCC.
+ if self.cxx.type != 'gcc':
+ self.cxx.warning_flags += ['-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER']
if self.cxx.hasWarningFlag('-Wuser-defined-warnings'):
self.cxx.warning_flags += ['-Wuser-defined-warnings']
self.config.available_features.add('diagnose-if-support')
@@ -849,11 +851,7 @@ def configure_warnings(self):
self.cxx.addWarningFlagIfSupported('-Wunused-variable')
self.cxx.addWarningFlagIfSupported('-Wunused-parameter')
self.cxx.addWarningFlagIfSupported('-Wunreachable-code')
- std = self.get_lit_conf('std', None)
- if std in ['c++98', 'c++03']:
- # The '#define static_assert' provided by libc++ in C++03 mode
- # causes an unused local typedef whenever it is used.
- self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef')
+ self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef')
def configure_sanitizer(self):
san = self.get_lit_conf('use_sanitizer', '').strip()
@@ -982,8 +980,9 @@ def configure_substitutions(self):
sub.append(('%{libcxx_src_root}', self.libcxx_src_root))
# Configure flags substitutions
flags = self.cxx.flags + (self.cxx.modules_flags if self.cxx.use_modules else [])
+ compile_flags = self.cxx.compile_flags + self.cxx.warning_flags
sub.append(('%{flags}', ' '.join(map(pipes.quote, flags))))
- sub.append(('%{compile_flags}', ' '.join(map(pipes.quote, self.cxx.compile_flags))))
+ sub.append(('%{compile_flags}', ' '.join(map(pipes.quote, compile_flags))))
sub.append(('%{link_flags}', ' '.join(map(pipes.quote, self.cxx.link_flags))))
sub.append(('%{link_libcxxabi}', pipes.quote(self.cxx.link_libcxxabi_flag)))
diff --git a/libcxx/utils/libcxx/test/newformat.py b/libcxx/utils/libcxx/test/newformat.py
index f704b968b6da..31720ac9f2e8 100644
--- a/libcxx/utils/libcxx/test/newformat.py
+++ b/libcxx/utils/libcxx/test/newformat.py
@@ -173,33 +173,37 @@ def execute(self, test, litConfig):
if '-fmodules' in test.config.available_features and self._disableWithModules(test, litConfig):
return lit.Test.Result(lit.Test.UNSUPPORTED, 'Test {} is unsupported when modules are enabled')
+ # TODO(ldionne): Enable -Werror with all supported compilers.
+ clangOrAppleClang = {'clang', 'apple-clang'}.intersection(test.config.available_features) != set()
+ werror = '-Werror' if clangOrAppleClang else ''
+
if re.search('[.]sh[.][^.]+$', filename):
steps = [ ] # The steps are already in the script
return self._executeShTest(test, litConfig, steps)
elif filename.endswith('.compile.pass.cpp'):
steps = [
- "%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} -fsyntax-only"
+ "%dbg(COMPILED WITH) %{{cxx}} %s {} %{{flags}} %{{compile_flags}} -fsyntax-only".format(werror)
]
return self._executeShTest(test, litConfig, steps)
elif filename.endswith('.compile.fail.cpp'):
steps = [
- "%dbg(COMPILED WITH) ! %{cxx} %s %{flags} %{compile_flags} -fsyntax-only"
+ "%dbg(COMPILED WITH) ! %{{cxx}} %s {} %{{flags}} %{{compile_flags}} -fsyntax-only".format(werror)
]
return self._executeShTest(test, litConfig, steps)
elif filename.endswith('.link.pass.cpp'):
steps = [
- "%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe"
+ "%dbg(COMPILED WITH) %{{cxx}} %s {} %{{flags}} %{{compile_flags}} %{{link_flags}} -o %t.exe".format(werror)
]
return self._executeShTest(test, litConfig, steps)
elif filename.endswith('.link.fail.cpp'):
steps = [
- "%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} -c -o %t.o",
+ "%dbg(COMPILED WITH) %{{cxx}} %s {} %{{flags}} %{{compile_flags}} -c -o %t.o".format(werror),
"%dbg(LINKED WITH) ! %{cxx} %t.o %{flags} %{link_flags} -o %t.exe"
]
return self._executeShTest(test, litConfig, steps)
elif filename.endswith('.run.fail.cpp'):
steps = [
- "%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe",
+ "%dbg(COMPILED WITH) %{{cxx}} %s {} %{{flags}} %{{compile_flags}} %{{link_flags}} -o %t.exe".format(werror),
"%dbg(EXECUTED AS) %{exec} ! %t.exe"
]
return self._executeShTest(test, litConfig, steps, fileDependencies=['%t.exe'])
@@ -212,7 +216,7 @@ def execute(self, test, litConfig):
# suffixes above too.
elif filename.endswith('.pass.cpp') or filename.endswith('.pass.mm'):
steps = [
- "%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} %{link_flags} -o %t.exe",
+ "%dbg(COMPILED WITH) %{{cxx}} %s {} %{{flags}} %{{compile_flags}} %{{link_flags}} -o %t.exe".format(werror),
"%dbg(EXECUTED AS) %{exec} %t.exe"
]
return self._executeShTest(test, litConfig, steps, fileDependencies=['%t.exe'])
@@ -226,7 +230,7 @@ def execute(self, test, litConfig):
]
else:
steps = [
- "%dbg(COMPILED WITH) ! %{cxx} %s %{flags} %{compile_flags} -fsyntax-only"
+ "%dbg(COMPILED WITH) ! %{{cxx}} {} %s %{{flags}} %{{compile_flags}} -fsyntax-only".format(werror)
]
return self._executeShTest(test, litConfig, steps)
else:
More information about the libcxx-commits
mailing list