//
//===----------------------------------------------------------------------===//
-// Make sure the test passes if it fails at compile-time, without verify
+// Make sure the test passes if we don't have clang-verify support and
+// the test fails to compile.
+
+// UNSUPPORTED: verify-support
struct Foo { };
typedef Foo::x x;
-
-int main() { }
// XFAIL: *
-// Make sure the test DOES NOT pass if it succeeds at compile-time
+// Make sure the test DOES NOT pass if we don't have clang-verify support and
+// the test compiles successfully.
+
+// UNSUPPORTED: verify-support
int main() { }
--- /dev/null
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: verify-support
+
+// XFAIL: *
+
+// Make sure the test DOES NOT pass if there are no diagnostics, but we didn't
+// use the 'expected-no-diagnostics' markup.
+//
+// Note: For the purpose of this test, make sure the file would otherwise
+// compile to make sure we really fail due to a lack of markup.
+
+int main() { }
-// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
//
//===----------------------------------------------------------------------===//
-#error This test should not compile.
+// REQUIRES: verify-support
+
+// Make sure the test passes if we expected no diagnostics and included
+// the markup.
+
+// expected-no-diagnostics
//
//===----------------------------------------------------------------------===//
-// Make sure the test passes if it fails at compile-time, with verify
+// REQUIRES: verify-support
+
+// Make sure the test passes if it fails at compile-time with the expected
+// diagnostic.
struct Foo { };
typedef Foo::x x; // expected-error{{no type named 'x' in 'Foo'}}
// XFAIL: *
-// Make sure the test DOES NOT pass if it fails at compile-time, but the
-// expected-error is wrong.
+// Make sure the test DOES NOT pass if the expected diagnostic is wrong.
struct Foo { };
typedef Foo::x x; // expected-error{{this is not found in the errors}}
FOO.verify.cpp - Compiles with clang-verify
- FOO.fail.cpp - Does not compile successfully -- run with clang-verify
- if any expected-meow appears in the file, otherwise
- just test that compilation fails. This is supported
- only for backwards compatibility with the test suite
+ FOO.fail.cpp - Compiled with clang-verify if clang-verify is
+ supported, and equivalent to a .compile.fail.cpp
+ test otherwise. This is supported only for backwards
+ compatibility with the test suite.
The test format operates by assuming that each test's configuration provides
the following substitutions, which it will reuse in the shell scripts it
for s in ['%{cxx}', '%{compile_flags}', '%{link_flags}', '%{flags}', '%{exec}']:
assert s in substitutions, "Required substitution {} was not provided".format(s)
- # Determine whether -verify should be used for a given test. We use -verify
- # if the compiler supports it and there's at least one -verify tag in the
- # source file.
- #
- # This is only supported for backwards compatibility with .fail.cpp tests.
- def _useVerify(self, test, litConfig):
- VERIFY_TAGS = (b'expected-note', b'expected-remark',
- b'expected-warning', b'expected-error',
- b'expected-no-diagnostics')
- with open(test.getSourcePath(), 'rb') as f:
- contents = f.read()
- testContainsTags = any(tag in contents for tag in VERIFY_TAGS)
-
+ # Determine whether clang-verify is supported.
+ def _supportsVerify(self, test, litConfig):
command = "echo | %{cxx} -xc++ - -Werror -fsyntax-only -Xclang -verify-ignore-unexpected"
result = lit.TestRunner.executeShTest(test, litConfig,
useExternalSh=True,
preamble_commands=[command])
compilerSupportsVerify = result.code != lit.Test.FAIL
- return compilerSupportsVerify and testContainsTags
+ return compilerSupportsVerify
def _disableWithModules(self, test, litConfig):
with open(test.getSourcePath(), 'rb') as f:
# otherwise it's like a .compile.fail.cpp test. This is only provided
# for backwards compatibility with the test suite.
elif filename.endswith('.fail.cpp'):
- if self._useVerify(test, litConfig):
+ if self._supportsVerify(test, litConfig):
steps = [
"%dbg(COMPILED WITH) %{cxx} %s %{flags} %{compile_flags} -fsyntax-only " + VERIFY_FLAGS
]