diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Analysis/ptr-arith.c | 2 | ||||
-rw-r--r-- | test/Analysis/retain-release-gc-only.m | 49 | ||||
-rw-r--r-- | test/Analysis/retain-release.m | 28 | ||||
-rw-r--r-- | test/CMakeLists.txt | 53 | ||||
-rw-r--r-- | test/CodeGen/attributes.c | 12 | ||||
-rw-r--r-- | test/CodeGen/x86_64-arguments.c | 6 | ||||
-rw-r--r-- | test/CodeGenObjC/blocks-3.m | 15 | ||||
-rw-r--r-- | test/Driver/flags.c | 6 | ||||
-rw-r--r-- | test/Driver/redzone.c | 6 | ||||
-rw-r--r-- | test/Parser/pragma-weak.c | 17 | ||||
-rw-r--r-- | test/Sema/const-eval.c | 1 | ||||
-rw-r--r-- | test/SemaObjCXX/references.mm | 27 | ||||
-rw-r--r-- | test/SemaTemplate/ackermann.cpp | 37 | ||||
-rw-r--r-- | test/SemaTemplate/default-arguments.cpp | 3 | ||||
-rw-r--r-- | test/SemaTemplate/temp_class_spec.cpp | 84 |
15 files changed, 340 insertions, 6 deletions
diff --git a/test/Analysis/ptr-arith.c b/test/Analysis/ptr-arith.c index ea8b7f5..34840c7 100644 --- a/test/Analysis/ptr-arith.c +++ b/test/Analysis/ptr-arith.c @@ -18,7 +18,7 @@ void f2() { // This test case checks if we get the right rvalue type of a TypedViewRegion. // The ElementRegion's type depends on the array region's rvalue type. If it was // a pointer type, we would get a loc::SymbolVal for '*p'. -char* memchr(); +void* memchr(); static int domain_port (const char *domain_b, const char *domain_e, const char **domain_e_ptr) diff --git a/test/Analysis/retain-release-gc-only.m b/test/Analysis/retain-release-gc-only.m index cc4a40d..ec33a57 100644 --- a/test/Analysis/retain-release-gc-only.m +++ b/test/Analysis/retain-release-gc-only.m @@ -5,6 +5,8 @@ // Header stuff. //===----------------------------------------------------------------------===// +typedef struct objc_class *Class; + typedef unsigned int __darwin_natural_t; typedef struct {} div_t; typedef unsigned long UInt32; @@ -56,6 +58,7 @@ typedef struct _NSZone NSZone; @end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end @interface NSObject <NSObject> {} +- (Class)class; + (id)alloc; + (id)allocWithZone:(NSZone *)zone; @end typedef float CGFloat; @@ -173,6 +176,28 @@ void f5b() { @end //===----------------------------------------------------------------------===// +// <rdar://problem/6948053> False positive: object substitution during -init* +// methods warns about returning +0 when using -fobjc-gc-only +//===----------------------------------------------------------------------===// + +@interface MyClassRdar6948053 : NSObject +- (id) init; ++ (id) shared; +@end + +@implementation MyClassRdar6948053 ++(id) shared { + return (id) 0; +} +- (id) init +{ + Class myClass = [self class]; + [self release]; + return [[myClass shared] retain]; // no-warning +} +@end + +//===----------------------------------------------------------------------===// // Tests of ownership attributes. //===----------------------------------------------------------------------===// @@ -189,3 +214,27 @@ void test_attr_1b(TestOwnershipAttr *X) { NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}} } +@interface MyClassTestCFAttr : NSObject {} +- (NSDate*) returnsCFRetained __attribute__((cf_returns_retained)); +- (NSDate*) alsoReturnsRetained; +- (NSDate*) returnsNSRetained __attribute__((ns_returns_retained)); +@end + +__attribute__((cf_returns_retained)) +CFDateRef returnsRetainedCFDate() { + return CFDateCreate(0, CFAbsoluteTimeGetCurrent()); +} + +@implementation MyClassTestCFAttr +- (NSDate*) returnsCFRetained { + return (NSDate*) returnsRetainedCFDate(); // No leak. +} + +- (NSDate*) alsoReturnsRetained { + return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}} +} + +- (NSDate*) returnsNSRetained { + return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}} +} +@end
\ No newline at end of file diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index 3ff007e..c7c5e24 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -704,5 +704,31 @@ void test_attr_1(TestOwnershipAttr *X) { void test_attr_1b(TestOwnershipAttr *X) { NSString *str = [X returnsAnOwnedCFString]; // expected-warning{{leak}} } -//<<SLICER + +@interface MyClassTestCFAttr : NSObject {} +- (NSDate*) returnsCFRetained __attribute__((cf_returns_retained)); +- (NSDate*) alsoReturnsRetained; +- (NSDate*) returnsNSRetained __attribute__((ns_returns_retained)); +@end + +__attribute__((cf_returns_retained)) +CFDateRef returnsRetainedCFDate() { + return CFDateCreate(0, CFAbsoluteTimeGetCurrent()); +} + +@implementation MyClassTestCFAttr +- (NSDate*) returnsCFRetained { + return (NSDate*) returnsRetainedCFDate(); // No leak. +} + +- (NSDate*) alsoReturnsRetained { + return (NSDate*) returnsRetainedCFDate(); // expected-warning{{leak}} +} + +- (NSDate*) returnsNSRetained { + return (NSDate*) returnsRetainedCFDate(); // no-warning +} +@end + + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..ba5a025 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,53 @@ +find_file(CLANG_TEST_RUNNER TestRunner.sh PATHS ${CMAKE_CURRENT_SOURCE_DIR} + DOC "Clang's regression testing script") +mark_as_advanced(CLANG_TEST_RUNNER) + +set(CLANG_TEST_DIRECTORIES + "Analysis" + "CodeGen" + "CodeGenCXX" + "CodeGenObjC" + "Coverage" + "Driver" + "FixIt" + "Frontend" + "Lexer" + "Misc" + "PCH" + "Parser" + "Preprocessor" + "Rewriter" + "Sema" + "SemaCXX" + "SemaObjC" + "SemaObjCXX" + "SemaTemplate") + +include(FindPythonInterp) +if(PYTHONINTERP_FOUND) + get_target_property(LLVM_TOOLS_PATH clang RUNTIME_OUTPUT_DIRECTORY) + set(TESTING_EXTRA_PATHS + "${LLVM_TOOLS_PATH}/${CMAKE_CFG_INTDIR}:${LLVM_SOURCE_DIR}/test/Scripts") + set(all_testdirs) + foreach(testdir ${CLANG_TEST_DIRECTORIES}) + add_custom_target(clang-test-${testdir} + ${PYTHON_EXECUTABLE} + ${LLVM_SOURCE_DIR}/tools/clang/utils/test/MultiTestRunner.py + -s + "--path=${TESTING_EXTRA_PATHS}" + ${CMAKE_CURRENT_SOURCE_DIR}/${testdir}/ + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Running Clang regression tests in ${testdir}") + + list(APPEND all_testdirs ${CMAKE_CURRENT_SOURCE_DIR}/${testdir}/) + endforeach() + + add_custom_target(clang-test + ${PYTHON_EXECUTABLE} + ${LLVM_SOURCE_DIR}/tools/clang/utils/test/MultiTestRunner.py + "--path=${TESTING_EXTRA_PATHS}" + ${all_testdirs} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS clang clang-cc + COMMENT "Running Clang regression tests") +endif() diff --git a/test/CodeGen/attributes.c b/test/CodeGen/attributes.c index d45d512..a5de4f4 100644 --- a/test/CodeGen/attributes.c +++ b/test/CodeGen/attributes.c @@ -14,7 +14,7 @@ // RUN: grep '@t13 =.*section "SECT"' %t && // RUN: grep '@t14.x =.*section "SECT"' %t // RUN: grep 'declare extern_weak i32 @t15()' %t && -// RUN: grep '@t16 = extern_weak global i32' %t +// RUN: grep '@t16 = extern_weak global i32' %t && void t1() __attribute__((noreturn)); void t1() {} @@ -56,4 +56,14 @@ int t17() { return t15() + t16; } +// RUN: grep '@t18 = global i[0-9]* 1, align .*' %t && +extern int t18 __attribute__((weak_import)); +int t18 = 1; +// RUN: grep 'define i[0-9]* @t19() nounwind {' %t && +extern int t19(void) __attribute__((weak_import)); +int t19(void) { + return 10; +} + +// RUN: true diff --git a/test/CodeGen/x86_64-arguments.c b/test/CodeGen/x86_64-arguments.c index 6f7ec82..0b68afd 100644 --- a/test/CodeGen/x86_64-arguments.c +++ b/test/CodeGen/x86_64-arguments.c @@ -82,4 +82,10 @@ void f16(float a, float b, float c, float d, float e, float f, float g, float h, void f17(float a, float b, float c, float d, float e, float f, float g, float h, long double X) {} +// Check for valid coercion. +// RUN: grep '.1 = bitcast i64. .tmp to .struct.f18_s0.' %t && +// RUN: grep '.2 = load .struct.f18_s0. .1, align 1' %t && +// RUN: grep 'store .struct.f18_s0 .2, .struct.f18_s0. .f18_arg1' %t && +void f18(int a, struct f18_s0 { int f0; } f18_arg1) {} + // RUN: true diff --git a/test/CodeGenObjC/blocks-3.m b/test/CodeGenObjC/blocks-3.m new file mode 100644 index 0000000..96e436b --- /dev/null +++ b/test/CodeGenObjC/blocks-3.m @@ -0,0 +1,15 @@ +// RUN: clang-cc -triple x86_64-apple-darwin9 -emit-llvm -fblocks -o %t %s && +// RUN: grep 'object_assign' %t | count 11 && +// RUN: grep 'object_dispose' %t | count 29 + +int main() { + typedef id aid __attribute__((aligned(1))); + __block aid a1; + __block id a2 __attribute__((aligned(2))); + __block id a3 __attribute__((aligned(4))); + __block id a4 __attribute__((aligned(8))); + __block id a5, a6, a7; + __block void (^b)(); + ^{ a1=a2=a3=a4=a5=a6=a7=0; b = 0; }(); + return 0; +} diff --git a/test/Driver/flags.c b/test/Driver/flags.c index 53f3995..7c448fa 100644 --- a/test/Driver/flags.c +++ b/test/Driver/flags.c @@ -1,9 +1,9 @@ // RUN: clang -ccc-host-triple i386-apple-darwin9 -### -S -msoft-float %s 2> %t.log && -// RUN: grep '"--soft-float"' %t.log && +// RUN: grep '"--no-implicit-float"' %t.log && // RUN: clang -ccc-host-triple i386-apple-darwin9 -### -S -msoft-float -mno-soft-float %s 2> %t.log && -// RUN: grep '"--soft-float"' %t.log | count 0 && +// RUN: grep '"--no-implicit-float"' %t.log | count 0 && // RUN: clang -ccc-host-triple i386-apple-darwin9 -### -S -mno-soft-float %s -msoft-float 2> %t.log && -// RUN: grep '"--soft-float"' %t.log +// RUN: grep '"--no-implicit-float"' %t.log diff --git a/test/Driver/redzone.c b/test/Driver/redzone.c new file mode 100644 index 0000000..8709e71 --- /dev/null +++ b/test/Driver/redzone.c @@ -0,0 +1,6 @@ +// RUN: clang -mno-red-zone %s -S -emit-llvm -o %t.log && +// RUN: grep 'noredzone' %t.log +// RUN: clang -mred-zone %s -S -emit-llvm -o %t.log && +// RUN: grep -v 'noredzone' %t.log + +int foo() { return 42; } diff --git a/test/Parser/pragma-weak.c b/test/Parser/pragma-weak.c new file mode 100644 index 0000000..355a954 --- /dev/null +++ b/test/Parser/pragma-weak.c @@ -0,0 +1,17 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +// Note that this puts the expected lines before the directives to work around +// limitations in the -verify mode. + +int x; +/* expected-warning {{expected identifier in '#pragma weak'}}*/ #pragma weak +#pragma weak x + +extern int z; +/* expected-warning {{expected identifier in '#pragma weak'}}*/ #pragma weak z = = +/* expected-warning {{expected identifier in '#pragma weak'}}*/ #pragma weak z = +#pragma weak z = y + +extern int a; +/* expected-warning {{extra tokens at end of '#pragma weak'}}*/ #pragma weak a b +/* expected-warning {{extra tokens at end of '#pragma weak'}}*/ #pragma weak a = x c diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index 79f96b9..971986b 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -65,3 +65,4 @@ static const struct a V1 = (struct a){ 1, 2}; EVAL_EXPR(30, (int)(_Complex float)((1<<30)-1) == (1<<30) ? 1 : -1) EVAL_EXPR(31, (int*)0 == (int*)0 ? 1 : -1) EVAL_EXPR(32, (int*)0 != (int*)0 ? -1 : 1) +EVAL_EXPR(33, (void*)0 - (void*)0 == 0 ? 1 : -1) diff --git a/test/SemaObjCXX/references.mm b/test/SemaObjCXX/references.mm new file mode 100644 index 0000000..6a28ea9 --- /dev/null +++ b/test/SemaObjCXX/references.mm @@ -0,0 +1,27 @@ +// RUN: clang-cc -verify -emit-llvm -o %t %s +// XFAIL + +// Test reference binding. + +typedef struct { + int f0; + int f1; +} T; + +@interface A +@property (assign) T p0; +@property (assign) T& p1; +@end + +int f0(const T& t) { + return t.f0; +} + +int f1(A *a) { + return f0(a.p0); +} + +int f2(A *a) { + return f0(a.p1); +} + diff --git a/test/SemaTemplate/ackermann.cpp b/test/SemaTemplate/ackermann.cpp new file mode 100644 index 0000000..48fbbbb --- /dev/null +++ b/test/SemaTemplate/ackermann.cpp @@ -0,0 +1,37 @@ +// RUN: clang-cc -fsyntax-only -ftemplate-depth=1000 -verify %s + +// template<unsigned M, unsigned N> +// struct Ackermann { +// enum { +// value = M ? (N ? Ackermann<M-1, Ackermann<M-1, N-1> >::value +// : Ackermann<M-1, 1>::value) +// : N + 1 +// }; +// }; + +template<unsigned M, unsigned N> +struct Ackermann { + enum { + value = Ackermann<M-1, Ackermann<M, N-1>::value >::value + }; +}; + +template<unsigned M> struct Ackermann<M, 0> { + enum { + value = Ackermann<M-1, 1>::value + }; +}; + +template<unsigned N> struct Ackermann<0, N> { + enum { + value = N + 1 + }; +}; + +template<> struct Ackermann<0, 0> { + enum { + value = 1 + }; +}; + +int g0[Ackermann<3, 8>::value == 2045 ? 1 : -1]; diff --git a/test/SemaTemplate/default-arguments.cpp b/test/SemaTemplate/default-arguments.cpp index 572227c..5b6ab7d 100644 --- a/test/SemaTemplate/default-arguments.cpp +++ b/test/SemaTemplate/default-arguments.cpp @@ -10,3 +10,6 @@ X<> *x3; // expected-error{{too few template arguments for class template 'X'}} template<typename U = float, int M> struct X; X<> *x4; + +template<typename T = int> struct Z { }; +template struct Z<>; diff --git a/test/SemaTemplate/temp_class_spec.cpp b/test/SemaTemplate/temp_class_spec.cpp index df652b5..8cb46cf 100644 --- a/test/SemaTemplate/temp_class_spec.cpp +++ b/test/SemaTemplate/temp_class_spec.cpp @@ -18,3 +18,87 @@ int array0[is_pointer<int>::value? -1 : 1]; int array1[is_pointer<int*>::value? 1 : -1]; int array2[is_pointer<const int*>::value? 1 : -1]; // expected-error{{partial ordering}} \ // expected-error{{negative}} + +template<typename T> +struct is_lvalue_reference { + static const bool value = false; +}; + +template<typename T> +struct is_lvalue_reference<T&> { + static const bool value = true; +}; + +int lvalue_ref0[is_lvalue_reference<int>::value? -1 : 1]; +int lvalue_ref1[is_lvalue_reference<const int&>::value? 1 : -1]; + +template<typename T, typename U> +struct is_same { + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +typedef int INT; +typedef INT* int_ptr; + +int is_same0[is_same<int, int>::value? 1 : -1]; +int is_same1[is_same<int, INT>::value? 1 : -1]; +int is_same2[is_same<const int, int>::value? -1 : 1]; +int is_same3[is_same<int_ptr, int>::value? -1 : 1]; + +template<typename T> +struct remove_reference { + typedef T type; +}; + +template<typename T> +struct remove_reference<T&> { + typedef T type; +}; + +int remove_ref0[is_same<remove_reference<int>::type, int>::value? 1 : -1]; +int remove_ref1[is_same<remove_reference<int&>::type, int>::value? 1 : -1]; + +template<typename T> +struct is_incomplete_array { + static const bool value = false; +}; + +template<typename T> +struct is_incomplete_array<T[]> { + static const bool value = true; +}; + +int incomplete_array0[is_incomplete_array<int>::value ? -1 : 1]; +int incomplete_array1[is_incomplete_array<int[1]>::value ? -1 : 1]; +int incomplete_array2[is_incomplete_array<bool[]>::value ? 1 : -1]; +int incomplete_array3[is_incomplete_array<int[]>::value ? 1 : -1]; + +template<typename T> +struct is_array_with_4_elements { + static const bool value = false; +}; + +template<typename T> +struct is_array_with_4_elements<T[4]> { + static const bool value = true; +}; + +int array_with_4_elements0[is_array_with_4_elements<int[]>::value ? -1 : 1]; +int array_with_4_elements1[is_array_with_4_elements<int[1]>::value ? -1 : 1]; +int array_with_4_elements2[is_array_with_4_elements<int[4]>::value ? 1 : -1]; +int array_with_4_elements3[is_array_with_4_elements<int[4][2]>::value ? 1 : -1]; + +template<typename T> +struct get_array_size; + +template<typename T, unsigned N> +struct get_array_size<T[N]> { + static const unsigned value = N; +}; + +int array_size0[get_array_size<int[12]>::value == 12? 1 : -1]; |