diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-03 15:20:48 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-03 15:20:48 +0000 |
commit | 551c698530debaae81139c7c76a29fb762793362 (patch) | |
tree | 547e0e59163c33f2142998714eb5f957e65d1a57 /test | |
parent | 416ada0f75bab22b084a1776deb229cd4a669c4d (diff) |
Notes
Diffstat (limited to 'test')
32 files changed, 324 insertions, 56 deletions
diff --git a/test/CodeGen/pr26099.c b/test/CodeGen/pr26099.c new file mode 100644 index 000000000000..15b73b832e9d --- /dev/null +++ b/test/CodeGen/pr26099.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -ffreestanding %s -triple=i686-apple-darwin -target-feature +mmx -emit-llvm -o - -Wall -Werror +// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +mmx -emit-llvm -o - -Wall -Werror +// REQUIRES: asserts + +#include <x86intrin.h> + +int __attribute__ ((__vector_size__ (8))) b; + +void bar(int a) +{ + b = __builtin_ia32_vec_init_v2si (0, a); +}
\ No newline at end of file diff --git a/test/CodeGen/thin_link_bitcode.c b/test/CodeGen/thin_link_bitcode.c index 4cb5f798a568..52c5715ba561 100644 --- a/test/CodeGen/thin_link_bitcode.c +++ b/test/CodeGen/thin_link_bitcode.c @@ -1,6 +1,11 @@ +// REQUIRES: x86-registered-target +// // RUN: %clang_cc1 -o %t -flto=thin -fthin-link-bitcode=%t.nodebug -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s // RUN: llvm-bcanalyzer -dump %t | FileCheck %s // RUN: llvm-bcanalyzer -dump %t.nodebug | FileCheck %s --check-prefix=NO_DEBUG +// RUN: %clang_cc1 -o %t.newpm -flto=thin -fexperimental-new-pass-manager -fthin-link-bitcode=%t.newpm.nodebug -triple x86_64-unknown-linux-gnu -emit-llvm-bc -debug-info-kind=limited %s +// RUN: llvm-bcanalyzer -dump %t.newpm | FileCheck %s +// RUN: llvm-bcanalyzer -dump %t.newpm.nodebug | FileCheck %s --check-prefix=NO_DEBUG int main (void) { return 0; } diff --git a/test/CodeGen/ubsan-pointer-overflow.m b/test/CodeGen/ubsan-pointer-overflow.m index c83d527e624e..56df95baff55 100644 --- a/test/CodeGen/ubsan-pointer-overflow.m +++ b/test/CodeGen/ubsan-pointer-overflow.m @@ -37,9 +37,9 @@ void binary_arith(char *p, int i) { // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize // CHECK-NEXT: [[POSOFFSET:%.*]] = icmp sge i64 [[SMULVAL]], 0, !nosanitize - // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize - // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize - // CHECK-NEXT: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize + // CHECK-DAG: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize + // CHECK-DAG: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize + // CHECK: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[COMPGEP]]){{.*}}, !nosanitize p + i; @@ -62,9 +62,9 @@ void fixed_len_array(int k) { // CHECK-NEXT: [[POSVALID:%.*]] = icmp uge i64 [[COMPGEP]], [[BASE]], !nosanitize // CHECK-NEXT: [[NEGVALID:%.*]] = icmp ult i64 [[COMPGEP]], [[BASE]], !nosanitize // CHECK-NEXT: [[POSOFFSET:%.*]] = icmp sge i64 [[SMULVAL]], 0, !nosanitize - // CHECK-NEXT: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize - // CHECK-NEXT: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize - // CHECK-NEXT: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize + // CHECK-DAG: [[OFFSETVALID:%.*]] = xor i1 [[OFFSETOFLOW]], true, !nosanitize + // CHECK-DAG: [[DIFFVALID:%.*]] = select i1 [[POSOFFSET]], i1 [[POSVALID]], i1 [[NEGVALID]], !nosanitize + // CHECK: [[VALID:%.*]] = and i1 [[OFFSETVALID]], [[DIFFVALID]], !nosanitize // CHECK-NEXT: br i1 [[VALID]]{{.*}}, !nosanitize // CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}, i64 [[BASE]], i64 [[COMPGEP]]){{.*}}, !nosanitize diff --git a/test/CodeGenCXX/pr33080.cpp b/test/CodeGenCXX/pr33080.cpp new file mode 100644 index 000000000000..a744bca18986 --- /dev/null +++ b/test/CodeGenCXX/pr33080.cpp @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm -o- %s | FileCheck %s + +void fa(__unaligned struct A *) {} +// CHECK: define void @_Z2faPU11__unaligned1A( + +void ga(struct A *, struct A *) {} +// CHECK: define void @_Z2gaP1AS0_( + +void gb(__unaligned struct A *, struct A *) {} +// CHECK: define void @_Z2gbPU11__unaligned1APS_( + +void gc(struct A *, __unaligned struct A *) {} +// CHECK: define void @_Z2gcP1APU11__unalignedS_( + +void gd(__unaligned struct A *, __unaligned struct A *) {} +// CHECK: define void @_Z2gdPU11__unaligned1AS1_( + +void hb(__unaligned struct A *, __unaligned const struct A *) {} +// CHECK: define void @_Z2hbPU11__unaligned1APU11__unalignedKS_( + +void ja(__unaligned struct A *, __unaligned struct A *__unaligned *, __unaligned struct A *__unaligned *__unaligned *) {} +// CHECK: define void @_Z2jaPU11__unaligned1APU11__unalignedS1_PU11__unalignedS3_( + +void jb(__unaligned struct A *, __unaligned struct A **, __unaligned struct A *__unaligned *__unaligned *) {} +// CHECK: @_Z2jbPU11__unaligned1APS1_PU11__unalignedPU11__unalignedS1_( + +template <typename T, typename Q> +void ta(T &, Q *) {} + +void ia(__unaligned struct A &a) { + ta(a, &a); +} +// CHECK: @_Z2taIU11__unaligned1AS1_EvRT_PT0_( diff --git a/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp b/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp deleted file mode 100644 index a23e6a47ab05..000000000000 --- a/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm-only %s -verify - -struct A -{ - int x; - void foo() __unaligned; - void foo(); -}; - -void A::foo() __unaligned -{ - this->x++; -} - -void A::foo() // expected-error {{definition with same mangled name as another definition}} - // expected-note@-6 {{previous definition is here}} -{ - this->x++; -} - diff --git a/test/CodeGenCXX/unaligned-member-qualifier.cpp b/test/CodeGenCXX/unaligned-member-qualifier.cpp new file mode 100644 index 000000000000..0d326a666830 --- /dev/null +++ b/test/CodeGenCXX/unaligned-member-qualifier.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm %s -o- | FileCheck %s + +struct A { + void foo() __unaligned; + void foo() const __unaligned; + void foo() volatile __unaligned; + void foo() const volatile __unaligned; +}; + +void A::foo() __unaligned {} +// CHECK: define [[THISCALL:(x86_thiscallcc )?]]void @_ZNU11__unaligned1A3fooEv( + +void A::foo() const __unaligned {} +// CHECK: define [[THISCALL]]void @_ZNU11__unalignedK1A3fooEv( + +void A::foo() volatile __unaligned {} +// CHECK: define [[THISCALL]]void @_ZNU11__unalignedV1A3fooEv( + +void A::foo() const volatile __unaligned {} +// CHECK: define [[THISCALL]]void @_ZNU11__unalignedVK1A3fooEv( diff --git a/test/CodeGenCoroutines/coro-params.cpp b/test/CodeGenCoroutines/coro-params.cpp index c88e503a651c..540f84585c8e 100644 --- a/test/CodeGenCoroutines/coro-params.cpp +++ b/test/CodeGenCoroutines/coro-params.cpp @@ -93,3 +93,37 @@ void f(int val, MoveOnly moParam, MoveAndCopy mcParam) { // CHECK-NEXT: call void @_ZN8MoveOnlyD1Ev(%struct.MoveOnly* %[[MoCopy]] // CHECK-NEXT: call i8* @llvm.coro.free( } + +// CHECK-LABEL: void @_Z16dependent_paramsI1A1BEvT_T0_S3_(%struct.A* %x, %struct.B*, %struct.B* %y) +template <typename T, typename U> +void dependent_params(T x, U, U y) { + // CHECK: %[[x_copy:.+]] = alloca %struct.A + // CHECK-NEXT: %[[unnamed_copy:.+]] = alloca %struct.B + // CHECK-NEXT: %[[y_copy:.+]] = alloca %struct.B + + // CHECK: call i8* @llvm.coro.begin + // CHECK-NEXT: call void @_ZN1AC1EOS_(%struct.A* %[[x_copy]], %struct.A* dereferenceable(512) %x) + // CHECK-NEXT: call void @_ZN1BC1EOS_(%struct.B* %[[unnamed_copy]], %struct.B* dereferenceable(512) %0) + // CHECK-NEXT: call void @_ZN1BC1EOS_(%struct.B* %[[y_copy]], %struct.B* dereferenceable(512) %y) + // CHECK-NEXT: invoke void @_ZNSt12experimental16coroutine_traitsIJv1A1BS2_EE12promise_typeC1Ev( + + co_return; +} + +struct A { + int WontFitIntoRegisterForSure[128]; + A(); + A(A&&) noexcept; + ~A(); +}; + +struct B { + int WontFitIntoRegisterForSure[128]; + B(); + B(B&&) noexcept; + ~B(); +}; + +void call_dependent_params() { + dependent_params(A{}, B{}, B{}); +} diff --git a/test/CodeGenObjCXX/arc-mangle.mm b/test/CodeGenObjCXX/arc-mangle.mm index 82e37556ec30..b39aa7bbbf00 100644 --- a/test/CodeGenObjCXX/arc-mangle.mm +++ b/test/CodeGenObjCXX/arc-mangle.mm @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -triple %itanium_abi_triple -emit-llvm -fblocks -o - %s | FileCheck %s +// RUN: %clang_cc1 -DTEST_UNALIGNED -fms-extensions -fobjc-arc -fobjc-runtime-has-weak -triple %itanium_abi_triple -emit-llvm -fblocks -o - %s | FileCheck %s --check-prefix=UNALIGNED // CHECK-LABEL: define {{.*}}void @_Z1fPU8__strongP11objc_object(i8**) void f(__strong id *) {} @@ -32,3 +33,12 @@ template<unsigned N> struct unsigned_c { }; // CHECK-LABEL: define weak_odr {{.*}}void @_Z1gIKvEvP10unsigned_cIXplszv1U8__bridgecvPT_v1U8__bridgecvP11objc_objectcvS3_Li0ELi1EEE template<typename T>void g(unsigned_c<sizeof((__bridge T*)(__bridge id)(T*)0) + 1>*) {} template void g<const void>(unsigned_c<sizeof(id) + 1> *); + +#if TEST_UNALIGNED +// UNALIGNED-LABEL: define {{.*}}void @_Z1gPU6__weakU11__unalignedP11objc_object(i8**) +void g(__weak __unaligned id *) {} +// UNALIGNED-LABEL: define {{.*}}void @_Z1gPU11__unalignedU8__strongP11objc_object(i8**) +void g(__strong __unaligned id *) {} +// UNALIGNED-LABEL: define {{.*}}void @_Z1gPU11__unalignedU15__autoreleasingP11objc_object(i8**) +void g(__autoreleasing __unaligned id *) {} +#endif // TEST_UNALIGNED diff --git a/test/Driver/fsanitize-coverage.c b/test/Driver/fsanitize-coverage.c index cf0941477bba..0516b6db524c 100644 --- a/test/Driver/fsanitize-coverage.c +++ b/test/Driver/fsanitize-coverage.c @@ -84,6 +84,9 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=no-prune,func,trace-pc-guard %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_NOPRUNE // CHECK_NOPRUNE: -fsanitize-coverage-no-prune +// RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=inline-8bit-counters %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_INLINE8BIT +// CHECK_INLINE8BIT: -fsanitize-coverage-inline-8bit-counters + // RUN: %clang_cl --target=i386-pc-win32 -fsanitize=address -fsanitize-coverage=func,trace-pc-guard -c -### -- %s 2>&1 | FileCheck %s -check-prefix=CLANG-CL-COVERAGE // CLANG-CL-COVERAGE-NOT: error: // CLANG-CL-COVERAGE-NOT: warning: diff --git a/test/Frontend/rewrite-includes-filenotfound.c b/test/Frontend/rewrite-includes-filenotfound.c new file mode 100644 index 000000000000..203dbde54516 --- /dev/null +++ b/test/Frontend/rewrite-includes-filenotfound.c @@ -0,0 +1,6 @@ +// RUN: not %clang_cc1 -E -frewrite-includes %s -o - 2>&1 | FileCheck %s + +#include "this file does not exist.foo" +#include "this file also does not exist.foo" + +CHECK: fatal error: {{.*}} file not found diff --git a/test/Integration/carbon.c b/test/Integration/carbon.c index 0498116dd181..3cae39122685 100644 --- a/test/Integration/carbon.c +++ b/test/Integration/carbon.c @@ -1,4 +1,5 @@ // RUN: %clang -fsyntax-only %s +// REQUIRES: macos-sdk-10.12 #ifdef __APPLE__ #include <Carbon/Carbon.h> #endif diff --git a/test/Integration/cocoa-pch.m b/test/Integration/cocoa-pch.m index 0159b3201492..fa3ccea37896 100644 --- a/test/Integration/cocoa-pch.m +++ b/test/Integration/cocoa-pch.m @@ -1,6 +1,7 @@ // RUN: %clang -arch x86_64 -x objective-c-header %s -o %t.h.pch // RUN: touch %t.empty.m // RUN: %clang -arch x86_64 -fsyntax-only %t.empty.m -include %t.h -Xclang -ast-dump 2>&1 > /dev/null +// REQUIRES: macos-sdk-10.12 #ifdef __APPLE__ #include <Cocoa/Cocoa.h> #endif diff --git a/test/Integration/cocoa.m b/test/Integration/cocoa.m index d814b3ee21bc..91d868250845 100644 --- a/test/Integration/cocoa.m +++ b/test/Integration/cocoa.m @@ -1,4 +1,5 @@ // RUN: %clang -arch x86_64 %s -fsyntax-only -Xclang -print-stats +// REQUIRES: macos-sdk-10.12 #ifdef __APPLE__ #include <Cocoa/Cocoa.h> #endif diff --git a/test/Misc/ast-print-objectivec.m b/test/Misc/ast-print-objectivec.m index e419237bbbac..cb5aacc06a49 100644 --- a/test/Misc/ast-print-objectivec.m +++ b/test/Misc/ast-print-objectivec.m @@ -17,25 +17,30 @@ @implementation I - (void)MethP __attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2))) {} - (void)MethI __attribute__((availability(macosx,introduced=10.1.0,deprecated=10.2))) {} + +- (void)methodWithArg:(int)x andAnotherOne:(int)y { } @end // CHECK: @protocol P -// CHECK: - (void) MethP __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))); +// CHECK: - (void)MethP __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))); // CHECK: @end // CHECK: @interface I : NSObject<P> -// CHECK: - (void) MethI __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))); +// CHECK: - (void)MethI __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))); // CHECK: @end // CHECK: @interface I(CAT) -// CHECK: - (void) MethCAT __attribute__((availability(macos, introduced=10_1_0, deprecated=10_2))); +// CHECK: - (void)MethCAT __attribute__((availability(macos, introduced=10_1_0, deprecated=10_2))); // CHECK: @end // CHECK: @implementation I -// CHECK: - (void) MethP __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))) { +// CHECK: - (void)MethP __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))) { +// CHECK: } + +// CHECK: - (void)MethI __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))) { // CHECK: } -// CHECK: - (void) MethI __attribute__((availability(macos, introduced=10.1.0, deprecated=10.2))) { +// CHECK: - (void)methodWithArg:(int)x andAnotherOne:(int)y { // CHECK: } // CHECK: @end diff --git a/test/Modules/Inputs/check-for-sanitizer-feature/check.h b/test/Modules/Inputs/check-for-sanitizer-feature/check.h new file mode 100644 index 000000000000..74b4628d1230 --- /dev/null +++ b/test/Modules/Inputs/check-for-sanitizer-feature/check.h @@ -0,0 +1,5 @@ +#if __has_feature(address_sanitizer) +#define HAS_ASAN 1 +#else +#define HAS_ASAN 0 +#endif diff --git a/test/Modules/Inputs/check-for-sanitizer-feature/map b/test/Modules/Inputs/check-for-sanitizer-feature/map new file mode 100644 index 000000000000..95f2da95020e --- /dev/null +++ b/test/Modules/Inputs/check-for-sanitizer-feature/map @@ -0,0 +1,3 @@ +module check_feature { + header "check.h" +} diff --git a/test/Modules/Inputs/header-attribs/bar.h b/test/Modules/Inputs/header-attribs/bar.h new file mode 100644 index 000000000000..796b4ebcc731 --- /dev/null +++ b/test/Modules/Inputs/header-attribs/bar.h @@ -0,0 +1 @@ +extern int b; diff --git a/test/Modules/Inputs/header-attribs/baz.h b/test/Modules/Inputs/header-attribs/baz.h new file mode 100644 index 000000000000..566a522b2474 --- /dev/null +++ b/test/Modules/Inputs/header-attribs/baz.h @@ -0,0 +1 @@ +extern int c; diff --git a/test/Modules/Inputs/header-attribs/foo.h b/test/Modules/Inputs/header-attribs/foo.h new file mode 100644 index 000000000000..a54d4a7067ee --- /dev/null +++ b/test/Modules/Inputs/header-attribs/foo.h @@ -0,0 +1 @@ +extern int a;
\ No newline at end of file diff --git a/test/Modules/Inputs/header-attribs/modular.modulemap b/test/Modules/Inputs/header-attribs/modular.modulemap new file mode 100644 index 000000000000..945d7150fd2f --- /dev/null +++ b/test/Modules/Inputs/header-attribs/modular.modulemap @@ -0,0 +1,5 @@ +module A { + header "foo.h" { size 13 } + header "bar.h" { size 1000 } + header "baz.h" { mtime 1 } +} diff --git a/test/Modules/Inputs/header-attribs/textual.modulemap b/test/Modules/Inputs/header-attribs/textual.modulemap new file mode 100644 index 000000000000..b73f3698aa02 --- /dev/null +++ b/test/Modules/Inputs/header-attribs/textual.modulemap @@ -0,0 +1,5 @@ +module A { + textual header "foo.h" { size 13 } + textual header "bar.h" { size 1000 } + textual header "baz.h" { mtime 1 } +} diff --git a/test/Modules/check-for-sanitizer-feature.cpp b/test/Modules/check-for-sanitizer-feature.cpp new file mode 100644 index 000000000000..40ae46c64684 --- /dev/null +++ b/test/Modules/check-for-sanitizer-feature.cpp @@ -0,0 +1,66 @@ +// RUN: rm -rf %t.1 %t.2 +// RUN: mkdir %t.1 %t.2 + +// Build and use an ASan-enabled module. +// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \ +// RUN: -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \ +// RUN: -I %S/Inputs/check-for-sanitizer-feature -verify %s +// RUN: ls %t.1 | count 2 + +// Force a module rebuild by disabling ASan. +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.1 \ +// RUN: -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \ +// RUN: -I %S/Inputs/check-for-sanitizer-feature -verify %s +// RUN: ls %t.1 | count 3 + +// Enable ASan again: check that there is no import failure, and no rebuild. +// RUN: %clang_cc1 -fsanitize=address -fmodules -fmodules-cache-path=%t.1 \ +// RUN: -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \ +// RUN: -I %S/Inputs/check-for-sanitizer-feature -verify %s +// RUN: ls %t.1 | count 3 + +// Some sanitizers can not affect AST generation when enabled. Check that +// module rebuilds don't occur when these sanitizers are enabled. +// +// First, build without any sanitization. +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.2 \ +// RUN: -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \ +// RUN: -I %S/Inputs/check-for-sanitizer-feature -verify %s +// RUN: ls %t.2 | count 2 +// +// Next, build with sanitization, and check that a new module isn't built. +// RUN: %clang_cc1 -fsanitize=cfi-vcall,unsigned-integer-overflow,nullability-arg,null -fmodules \ +// RUN: -fmodules-cache-path=%t.2 \ +// RUN: -fmodule-map-file=%S/Inputs/check-for-sanitizer-feature/map \ +// RUN: -I %S/Inputs/check-for-sanitizer-feature -verify %s +// RUN: ls %t.2 | count 2 + +// Finally, test that including enabled sanitizers in the module hash isn't +// required to ensure correctness of module imports. +// +// Emit a PCH with ASan enabled. +// RUN: %clang_cc1 -x c -fsanitize=address %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.asan_pch +// +// Import the PCH without ASan enabled (we expect an error). +// RUN: not %clang_cc1 -x c -include-pch %t.asan_pch %s -verify 2>&1 | FileCheck %s --check-prefix=PCH_MISMATCH +// PCH_MISMATCH: AST file was compiled with the target feature'-fsanitize=address' but the current translation unit is not +// +// Emit a PCH with UBSan enabled. +// RUN: %clang_cc1 -x c -fsanitize=null %S/Inputs/check-for-sanitizer-feature/check.h -emit-pch -o %t.ubsan_pch +// +// Import the PCH without UBSan enabled (should work just fine). +// RUN: %clang_cc1 -x c -include-pch %t.ubsan_pch %s -I %S/Inputs/check-for-sanitizer-feature -verify + +#include "check.h" + +#if __has_feature(address_sanitizer) +#if HAS_ASAN != 1 +#error Module doesn't have the address_sanitizer feature, but main program does. +#endif +#else +#if HAS_ASAN != 0 +#error Module has the address_sanitizer feature, but main program doesn't. +#endif +#endif + +// expected-no-diagnostics diff --git a/test/Modules/diagnostics.modulemap b/test/Modules/diagnostics.modulemap index 3b5b6a5c0396..865892b53b28 100644 --- a/test/Modules/diagnostics.modulemap +++ b/test/Modules/diagnostics.modulemap @@ -1,4 +1,4 @@ -// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-map-file=%S/Inputs/diagnostics-aux.modulemap -fmodule-map-file=%s -fsyntax-only -x c++ /dev/null 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-map-file=%S/Inputs/diagnostics-aux.modulemap -fmodule-map-file=%s -fsyntax-only -x c++ /dev/null 2>&1 | FileCheck %s --implicit-check-not error: // CHECK: In file included from {{.*}}diagnostics-aux.modulemap:3: // CHECK: diagnostics-aux-2.modulemap:2:3: error: expected @@ -15,3 +15,15 @@ module bad_use { // CHECK: diagnostics.modulemap:[[@LINE+1]]:22: error: use declarations are only allowed in top-level modules module submodule { use foo } } + +module header_attr { + // CHECK: diagnostics.modulemap:[[@LINE+1]]:20: error: expected a header attribute name + header "foo.h" { x } + // CHECK: diagnostics.modulemap:[[@LINE+1]]:27: error: header attribute 'size' specified multiple times + header "bar.h" { size 1 size 2 } + // CHECK: diagnostics.modulemap:[[@LINE+1]]:25: error: expected integer literal as value for header attribute 'size' + header "baz.h" { size "30 kilobytes" } + + header "quux.h" { size 1 mtime 2 } + header "no_attrs.h" {} +} diff --git a/test/Modules/header-attribs.cpp b/test/Modules/header-attribs.cpp new file mode 100644 index 000000000000..292a94561e45 --- /dev/null +++ b/test/Modules/header-attribs.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -I%S/Inputs/header-attribs -fmodule-map-file=%S/Inputs/header-attribs/textual.modulemap -fmodules-cache-path=%t -verify %s -fmodule-name=A -fmodules-strict-decluse +// RUN: not %clang_cc1 -fmodules -I%S/Inputs/header-attribs -emit-module -x c++-module-map %S/Inputs/header-attribs/modular.modulemap -fmodules-cache-path=%t -fmodule-name=A 2>&1 | FileCheck %s --check-prefix BUILD-MODULAR + +#include "foo.h" // ok, stats match +#include "bar.h" // expected-error {{does not depend on a module exporting 'bar.h'}} +#include "baz.h" // expected-error {{does not depend on a module exporting 'baz.h'}} + +// FIXME: Explain why the 'bar.h' found on disk doesn't match the module map. +// BUILD-MODULAR: error: header 'bar.h' not found diff --git a/test/Modules/lookup.m b/test/Modules/lookup.m index edf70639e5cc..b22e41f84594 100644 --- a/test/Modules/lookup.m +++ b/test/Modules/lookup.m @@ -14,7 +14,7 @@ void test(id x) { // expected-note@Inputs/lookup_right.h:3{{also found}} } -// CHECK-PRINT: - (int) method; -// CHECK-PRINT: - (double) method +// CHECK-PRINT: - (int)method; +// CHECK-PRINT: - (double)method // CHECK-PRINT: void test(id x) diff --git a/test/Modules/preprocess-missing.modulemap b/test/Modules/preprocess-missing.modulemap new file mode 100644 index 000000000000..300494672f2c --- /dev/null +++ b/test/Modules/preprocess-missing.modulemap @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fmodules -fmodule-name=A -x c++-module-map %s -emit-module -o /dev/null -verify +module A { + header "does not exist" { size 12345 } // ok, do not need mtime for explicit module build + header "also does not exist" { mtime 12345 } +} +#pragma clang module contents +// expected-error@4 {{cannot emit module A: size must be explicitly specified for missing header file "also does not exist"}} diff --git a/test/Modules/preprocess-module.cpp b/test/Modules/preprocess-module.cpp index 9d1a2bb6801f..1e9458e667e1 100644 --- a/test/Modules/preprocess-module.cpp +++ b/test/Modules/preprocess-module.cpp @@ -28,12 +28,21 @@ // RUN: %clang_cc1 -fmodules -fmodule-file=%t/no-rewrite.pcm %s -I%t -verify -fno-modules-error-recovery -DINCLUDE -I%S/Inputs/preprocess // RUN: %clang_cc1 -fmodules -fmodule-file=%t/rewrite.pcm %s -I%t -verify -fno-modules-error-recovery -DREWRITE -DINCLUDE -I%S/Inputs/preprocess +// Now try building the module when the header files are missing. +// RUN: cp %S/Inputs/preprocess/fwd.h %S/Inputs/preprocess/file.h %S/Inputs/preprocess/file2.h %S/Inputs/preprocess/module.modulemap %t +// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -I%t -x c++-module-map %t/module.modulemap -E -frewrite-includes -o %t/copy.ii +// RUN: rm %t/fwd.h %t/file.h %t/file2.h %t/module.modulemap +// RUN: %clang_cc1 -fmodules -fmodule-name=file -fmodule-file=%t/fwd.pcm -x c++-module-map-cpp-output %t/copy.ii -emit-module -o %t/copy.pcm + +// Finally, check that our module contains correct mapping information for the headers. +// RUN: cp %S/Inputs/preprocess/fwd.h %S/Inputs/preprocess/file.h %S/Inputs/preprocess/file2.h %S/Inputs/preprocess/module.modulemap %t +// RUN: %clang_cc1 -fmodules -fmodule-file=%t/copy.pcm %s -I%t -verify -fno-modules-error-recovery -DCOPY -DINCLUDE // == module map // CHECK: # 1 "{{.*}}module.modulemap" // CHECK: module file { -// CHECK: header "file.h" -// CHECK: header "file2.h" +// CHECK: header "file.h" { size +// CHECK: header "file2.h" { size // CHECK: } // == file.h @@ -98,6 +107,8 @@ __FILE *a; // expected-error {{declaration of '__FILE' must be imported}} #ifdef REWRITE // expected-note@rewrite.ii:1 {{here}} +#elif COPY +// expected-note@copy.ii:1 {{here}} #else // expected-note@no-rewrite.ii:1 {{here}} #endif diff --git a/test/Sema/warn-strict-prototypes.m b/test/Sema/warn-strict-prototypes.m index 4567dab01930..66d574f75f80 100644 --- a/test/Sema/warn-strict-prototypes.m +++ b/test/Sema/warn-strict-prototypes.m @@ -2,16 +2,16 @@ @interface Foo -@property (nonatomic, copy) void (^noProtoBlock)(); // expected-warning {{this function declaration is not a prototype}} +@property (nonatomic, copy) void (^noProtoBlock)(); // expected-warning {{this block declaration is not a prototype}} @property (nonatomic, copy) void (^block)(void); // no warning -- doStuff:(void (^)()) completionHandler; // expected-warning {{this function declaration is not a prototype}} +- doStuff:(void (^)()) completionHandler; // expected-warning {{this block declaration is not a prototype}} - doOtherStuff:(void (^)(void)) completionHandler; // no warning @end void foo() { - void (^block)() = // expected-warning {{this function declaration is not a prototype}} + void (^block)() = // expected-warning {{this block declaration is not a prototype}} ^void(int arg) { // no warning }; void (^block2)(void) = ^void() { // no warning @@ -19,3 +19,8 @@ void foo() { void (^block3)(void) = ^ { // no warning }; } + +void (*(^(*(^block4)()) // expected-warning {{this block declaration is not a prototype}} + ()) // expected-warning {{this function declaration is not a prototype}} + ()) // expected-warning {{this block declaration is not a prototype}} + (); // expected-warning {{this function declaration is not a prototype}} diff --git a/test/SemaCXX/coroutines.cpp b/test/SemaCXX/coroutines.cpp index a867cf68a6e1..4eedc2162f07 100644 --- a/test/SemaCXX/coroutines.cpp +++ b/test/SemaCXX/coroutines.cpp @@ -892,3 +892,16 @@ void test_bad_suspend() { co_await d; // OK } } + +template <int ID = 0> +struct NoCopy { + NoCopy(NoCopy const&) = delete; // expected-note 2 {{deleted here}} +}; +template <class T, class U> +void test_dependent_param(T t, U) { + // expected-error@-1 {{call to deleted constructor of 'NoCopy<0>'}} + // expected-error@-2 {{call to deleted constructor of 'NoCopy<1>'}} + ((void)t); + co_return 42; +} +template void test_dependent_param(NoCopy<0>, NoCopy<1>); // expected-note {{requested here}} diff --git a/test/SemaOpenCL/func.cl b/test/SemaOpenCL/func.cl index ea3bab6c514c..dc5b44057b19 100644 --- a/test/SemaOpenCL/func.cl +++ b/test/SemaOpenCL/func.cl @@ -4,8 +4,15 @@ void vararg_f(int, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} void __vararg_f(int, ...); typedef void (*vararg_fptr_t)(int, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} + // expected-error@-1{{pointers to functions are not allowed}} int printf(__constant const char *st, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} +// Struct type with function pointer field +typedef struct s +{ + void (*f)(struct s *self, int *i); // expected-error{{pointers to functions are not allowed}} +} s_t; + //Function pointer void foo(void*); diff --git a/test/SemaTemplate/deduction-crash.cpp b/test/SemaTemplate/deduction-crash.cpp index c94c9db94e06..74a25865aa20 100644 --- a/test/SemaTemplate/deduction-crash.cpp +++ b/test/SemaTemplate/deduction-crash.cpp @@ -1,14 +1,10 @@ -// RUN: not %clang_cc1 -fsyntax-only %s -std=c++11 2>&1| FileCheck %s - -// Note that the error count below doesn't matter. We just want to -// make sure that the parser doesn't crash. -// CHECK: 17 errors +// RUN: %clang_cc1 -fsyntax-only %s -std=c++1z -verify // PR7511 -template<a> +template<a> // expected-error +{{}} struct int_; -template<a> +template<a> // expected-error +{{}} template<int,typename T1,typename> struct ac { @@ -17,7 +13,7 @@ struct ac template<class>struct aaa { - typedef ac<1,int,int>::ae ae + typedef ac<1,int,int>::ae ae // expected-error +{{}} }; template<class> @@ -36,19 +32,19 @@ struct state_machine struct In; template<int my> - struct In<a::int_<aaa::a>,my>; + struct In<a::int_<aaa::a>,my>; // expected-error +{{}} template<class Event> int process(Event) { - In<a::int_<0> > a; + In<a::int_<0> > a; // expected-error +{{}} } - } + } // expected-error +{{}} template<class Event> int ant(Event) { region_processing_helper<int>* helper; - helper->process(0) + helper->process(0) // expected-error +{{}} } }; @@ -81,21 +77,21 @@ void endl( ) ; extern basic_ostream<char> cout; -int operator<<( basic_ostream<char> , pair ) ; +int operator<<( basic_ostream<char> , pair ) ; // expected-note +{{}} void register_object_imp ( ) { -cout << endl<1>; +cout << endl<1>; // expected-error +{{}} } // PR12933 -namespacae PR12933 { - template<typename S> +namespace PR12933 { + template<typename S> // expected-error +{{}} template<typename T> void function(S a, T b) {} int main() { - function(0, 1); + function(0, 1); // expected-error +{{}} return 0; } } @@ -142,3 +138,9 @@ namespace PR14281_part3 { template <class T, int* i> struct B {}; A<B<int, &some_decl>, &some_decl>::type x; } + +namespace var_template_partial_spec_incomplete { + template<typename T> int n; + template<typename T, typename U = void> int n<T *>; // expected-error +{{}} expected-note {{}} + int k = n<void *>; +} diff --git a/test/lit.cfg b/test/lit.cfg index a5e8b9de994b..e72eca6bd397 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -529,3 +529,6 @@ if run_console_tests != 0: config.available_features.add('console') lit.util.usePlatformSdkOnDarwin(config, lit_config) +macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config) +if macOSSDKVersion is not None: + config.available_features.add('macos-sdk-' + macOSSDKVersion) |