summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Analysis/NSString.m55
-rw-r--r--test/CodeGen/builtins-powi.c1
-rw-r--r--test/CodeGen/builtins.c3
-rw-r--r--test/CodeGen/const-init.c2
-rw-r--r--test/CodeGen/mandel.c2
-rw-r--r--test/CodeGenCXX/references.cpp9
-rw-r--r--test/CodeGenCXX/virt.cpp119
-rw-r--r--test/SemaCXX/incomplete-call.cpp6
-rw-r--r--test/SemaTemplate/explicit-instantiation.cpp21
-rw-r--r--test/SemaTemplate/temp_explicit.cpp1
10 files changed, 191 insertions, 28 deletions
diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m
index 0ba3cda6d580..a360075645f8 100644
--- a/test/Analysis/NSString.m
+++ b/test/Analysis/NSString.m
@@ -1,7 +1,13 @@
-// RUN: clang-cc -triple i386-pc-linux-gnu -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
-// RUN: clang-cc -triple i386-pc-linux-gnu -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s &&
-// RUN: clang-cc -triple i386-pc-linux-gnu -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s &&
-// RUN: clang-cc -triple i386-pc-linux-gnu -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s
+// RUN: clang-cc -triple i386-apple-darwin10 -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s &&
+// RUN: clang-cc -triple i386-apple-darwin10 -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s &&
+// RUN: clang-cc -DTEST_64 -triple x86_64-apple-darwin10 -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s &&
+// RUN: clang-cc -DTEST_64 -triple x86_64-apple-darwin10 -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s
+
+// ==-- FIXME: -analyzer-store=basic fails on this file (false negatives). --==
+// NOTWORK: clang-cc -triple i386-apple-darwin10 -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s &&
+// NOTWORK: clang-cc -triple i386-apple-darwin10 -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
+// NOTWORK: clang-cc -DTEST_64 -triple x86_64-apple-darwin10 -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
+// NOTWORK: clang-cc -DTEST_64 -triple x86_64-apple-darwin10 -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s
//===----------------------------------------------------------------------===//
// The following code is reduced using delta-debugging from
@@ -12,7 +18,18 @@
// both svelte and portable to non-Mac platforms.
//===----------------------------------------------------------------------===//
+#ifdef TEST_64
+typedef long long int64_t;
+_Bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue );
+#define COMPARE_SWAP_BARRIER OSAtomicCompareAndSwap64Barrier
+typedef int64_t intptr_t;
+#else
typedef int int32_t;
+_Bool OSAtomicCompareAndSwap32Barrier( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
+#define COMPARE_SWAP_BARRIER OSAtomicCompareAndSwap32Barrier
+typedef int32_t intptr_t;
+#endif
+
typedef const void * CFTypeRef;
typedef const struct __CFString * CFStringRef;
typedef const struct __CFAllocator * CFAllocatorRef;
@@ -263,7 +280,6 @@ id testSharedClassFromFunction() {
// Test OSCompareAndSwap
_Bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue );
-_Bool OSAtomicCompareAndSwap32Barrier( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
extern BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation);
void testOSCompareAndSwap() {
@@ -275,20 +291,29 @@ void testOSCompareAndSwap() {
[old release];
}
-void testOSCompareAndSwap32Barrier() {
+void testOSCompareAndSwapXXBarrier() {
NSString *old = 0;
NSString *s = [[NSString alloc] init]; // no-warning
- if (!OSAtomicCompareAndSwap32Barrier((int32_t) 0, (int32_t) s, (int32_t*) &old))
+ if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) &old))
[s release];
else
[old release];
}
-int testOSCompareAndSwap32Barrier_id(Class myclass, id xclass) {
- if (OSAtomicCompareAndSwap32Barrier(0, (int32_t) myclass, (int32_t*) &xclass))
+void testOSCompareAndSwapXXBarrier_positive() {
+ NSString *old = 0;
+ NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
+ if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) &old))
+ return;
+ else
+ [old release];
+}
+
+int testOSCompareAndSwapXXBarrier_id(Class myclass, id xclass) {
+ if (COMPARE_SWAP_BARRIER(0, (intptr_t) myclass, (intptr_t*) &xclass))
return 1;
return 0;
-}
+}
void test_objc_atomicCompareAndSwap() {
NSString *old = 0;
@@ -299,6 +324,16 @@ void test_objc_atomicCompareAndSwap() {
[old release];
}
+void test_objc_atomicCompareAndSwap_positive() {
+ NSString *old = 0;
+ NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
+ if (!objc_atomicCompareAndSwapPtr(0, s, &old))
+ return;
+ else
+ [old release];
+}
+
+
// Test stringWithFormat (<rdar://problem/6815234>)
void test_stringWithFormat() {
NSString *string = [[NSString stringWithFormat:@"%ld", (long) 100] retain];
diff --git a/test/CodeGen/builtins-powi.c b/test/CodeGen/builtins-powi.c
index 5b413a889502..57fa81a3ad12 100644
--- a/test/CodeGen/builtins-powi.c
+++ b/test/CodeGen/builtins-powi.c
@@ -3,7 +3,6 @@
#include <stdio.h>
#include <stdlib.h>
-#include <math.h>
void test(long double a, int b) {
printf("%Lf**%d: %08x %08x %016Lx\n",
diff --git a/test/CodeGen/builtins.c b/test/CodeGen/builtins.c
index 165db9c26753..ac59b274958a 100644
--- a/test/CodeGen/builtins.c
+++ b/test/CodeGen/builtins.c
@@ -2,7 +2,6 @@
// RUN: not grep __builtin %t
#include <stdio.h>
-#include <math.h>
void p(char *str, int x) {
printf("%s: %d\n", str, x);
@@ -118,7 +117,7 @@ int main() {
-void strcat() {}
+char *strcat(char *a, char const *b) {}
void foo() {
__builtin_strcat(0, 0);
diff --git a/test/CodeGen/const-init.c b/test/CodeGen/const-init.c
index 29e9c5561527..e25da9c6eba0 100644
--- a/test/CodeGen/const-init.c
+++ b/test/CodeGen/const-init.c
@@ -1,6 +1,6 @@
// RUN: clang-cc -triple i386-pc-linux-gnu -verify -emit-llvm -o - %s | FileCheck %s
-#include <stdint.h>
+typedef __INTPTR_TYPE__ intptr_t;
// Brace-enclosed string array initializers
char a[] = { "asdf" };
diff --git a/test/CodeGen/mandel.c b/test/CodeGen/mandel.c
index 6f46ee407f5c..27993f0559e9 100644
--- a/test/CodeGen/mandel.c
+++ b/test/CodeGen/mandel.c
@@ -25,8 +25,6 @@ int main() { return 0; }
#define I 1.0iF
-#include <math.h>
-
#include <stdio.h>
volatile double __complex__ accum;
diff --git a/test/CodeGenCXX/references.cpp b/test/CodeGenCXX/references.cpp
index c235521d43b1..32d46b3e104b 100644
--- a/test/CodeGenCXX/references.cpp
+++ b/test/CodeGenCXX/references.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-cc -verify -emit-llvm -o %t %s
+// RUN: clang-cc -verify -emit-llvm -o - %s | FileCheck %s
void t1() {
extern int& a;
@@ -100,3 +100,10 @@ void f(A* a) {
void *foo = 0;
void * const & kFoo = foo;
+struct D : C { D(); ~D(); };
+
+void h() {
+ // CHECK: call void @_ZN1DD1Ev
+ const C& c = D();
+}
+
diff --git a/test/CodeGenCXX/virt.cpp b/test/CodeGenCXX/virt.cpp
index 9ae81e5d3f33..21fecac11e7b 100644
--- a/test/CodeGenCXX/virt.cpp
+++ b/test/CodeGenCXX/virt.cpp
@@ -930,6 +930,124 @@ struct test15_D : test15_NV1, virtual test15_B2 {
// CHECK-LP32-NEXT: .long __ZN8test15_B4foo3Ev
+struct test16_NV1 {
+ virtual void fooNV1() { }
+virtual void foo_NV1() { }
+ int i;
+};
+
+struct test16_NV2 {
+ virtual test16_NV2* foo1() { return 0; }
+virtual void foo_NV2() { }
+virtual void foo_NV2b() { }
+ int i;
+};
+
+struct test16_B : public test16_NV1, test16_NV2 {
+ virtual test16_B *foo1() { return 0; }
+ virtual test16_B *foo2() { return 0; }
+ virtual test16_B *foo3() { return 0; }
+virtual void foo_B() { }
+ int i;
+};
+
+struct test16_B2 : test16_NV1, virtual test16_B {
+ virtual test16_B2 *foo1() { return 0; }
+ virtual test16_B2 *foo2() { return 0; }
+virtual void foo_B2() { }
+ int i;
+};
+
+struct test16_D : test16_NV1, virtual test16_B2 {
+ virtual test16_D *foo1() { return 0; }
+};
+
+// CHECK-LP64: __ZTV8test16_D:
+// CHECK-LP64-NEXT: .quad 32
+// CHECK-LP64-NEXT: .quad 16
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad __ZTI8test16_D
+// CHECK-LP64-NEXT: .quad __ZN10test16_NV16fooNV1Ev
+// CHECK-LP64-NEXT: .quad __ZN10test16_NV17foo_NV1Ev
+// CHECK-LP64-NEXT: .quad __ZN8test16_D4foo1Ev
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad 18446744073709551600
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad 16
+// CHECK-LP64-NEXT: .quad 18446744073709551600
+// CHECK-LP64-NEXT: .quad __ZTI8test16_D
+// CHECK-LP64-NEXT: .quad __ZN10test16_NV16fooNV1Ev
+// CHECK-LP64-NEXT: .quad __ZN10test16_NV17foo_NV1Ev
+// CHECK-LP64-NEXT: .quad __ZTcv0_n48_v0_n24_N8test16_D4foo1Ev
+// CHECK-LP64-NEXT: .quad __ZN9test16_B24foo2Ev
+// CHECK-LP64-NEXT: .quad __ZN9test16_B26foo_B2Ev
+// CHECK-LP64-NEXT .quad 16
+// CHECK-LP64-NEXT .quad 16
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64: .quad 18446744073709551600
+// CHECK-LP64: .quad 18446744073709551584
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .space 8
+// CHECK-LP64-NEXT: .quad 18446744073709551584
+// CHECK-LP64-NEXT: .quad __ZTI8test16_D
+// CHECK-LP64-NEXT: .quad __ZN10test16_NV16fooNV1Ev
+// CHECK-LP64-NEXT: .quad __ZN10test16_NV17foo_NV1Ev
+// CHECK-LP64-NEXT: .quad __ZTcv0_n40_v0_n32_N8test16_D4foo1Ev
+// CHECK-LP64-NEXT: .quad __ZTcv0_n48_v0_n24_N9test16_B24foo2Ev
+// CHECK-LP64-NEXT: .quad __ZN8test16_B4foo3Ev
+// CHECK-LP64-NEXT: .quad __ZN8test16_B5foo_BEv
+// CHECK-LP64-NEXT: .quad 18446744073709551568
+// CHECK-LP64-NEXT: .quad __ZTI8test16_D
+// CHECK-LP64-NEXT .quad __ZTcvn16_n40_v16_n32_N8test16_D4foo1Ev
+// CHECK-LP64: .quad __ZN10test16_NV27foo_NV2Ev
+// CHECK-LP64-NEXT: .quad __ZN10test16_NV28foo_NV2bEv
+
+// CHECK-LP32: __ZTV8test16_D:
+// CHECK-LP32-NEXT: .long 20
+// CHECK-LP32-NEXT: .long 8
+// CHECK-LP32-NEXT: .space 4
+// CHECK-LP32-NEXT: .long __ZTI8test16_D
+// CHECK-LP32-NEXT: .long __ZN10test16_NV16fooNV1Ev
+// CHECK-LP32-NEXT: .long __ZN10test16_NV17foo_NV1Ev
+// CHECK-LP32-NEXT: .long __ZN8test16_D4foo1Ev
+// CHECK-LP32-NEXT: .space 4
+// CHECK-LP32-NEXT: .space 4
+// CHECK-LP32-NEXT: .long 4294967288
+// CHECK-LP32-NEXT: .space 4
+// CHECK-LP32-NEXT: .space 4
+// CHECK-LP32-NEXT: .long 12
+// CHECK-LP32-NEXT: .long 4294967288
+// CHECK-LP32-NEXT: .long __ZTI8test16_D
+// CHECK-LP32-NEXT: .long __ZN10test16_NV16fooNV1Ev
+// CHECK-LP32-NEXT: .long __ZN10test16_NV17foo_NV1Ev
+// CHECK-LP32-NEXT: .long __ZTcv0_n24_v0_n12_N8test16_D4foo1Ev
+// CHECK-LP32-NEXT: .long __ZN9test16_B24foo2Ev
+// CHECK-LP32-NEXT: .long __ZN9test16_B26foo_B2Ev
+// CHECK-LP32-NEXT .long 8
+// CHECK-LP32-NEXT .long 8
+// CHECK-LP32-NEXT: .space 4
+// CHECK-LP32-NEXT: .space 4
+// CHECK-LP32: .long 4294967284
+// CHECK-LP32-NEXT: .long 4294967276
+// CHECK-LP32-NEXT: .space 4
+// CHECK-LP32-NEXT: .space 4
+// CHECK-LP32-NEXT: .long 4294967276
+// CHECK-LP32-NEXT: .long __ZTI8test16_D
+// CHECK-LP32-NEXT: .long __ZN10test16_NV16fooNV1Ev
+// CHECK-LP32-NEXT: .long __ZN10test16_NV17foo_NV1Ev
+// CHECK-LP32-NEXT: .long __ZTcv0_n20_v0_n16_N8test16_D4foo1Ev
+// CHECK-LP32-NEXT: .long __ZTcv0_n24_v0_n12_N9test16_B24foo2Ev
+// CHECK-LP32-NEXT: .long __ZN8test16_B4foo3Ev
+// CHECK-LP32-NEXT: .long __ZN8test16_B5foo_BEv
+// CHECK-LP32-NEXT: .long 4294967268
+// CHECK-LP32-NEXT: .long __ZTI8test16_D
+// CHECK-LP32-NEXT .long __ZTcvn8_n20_v8_n16_N8test16_D4foo1Ev
+// CHECK-LP32: .long __ZN10test16_NV27foo_NV2Ev
+// CHECK-LP32-NEXT: .long __ZN10test16_NV28foo_NV2bEv
+
// CHECK-LP64: __ZTV1B:
// CHECK-LP64-NEXT: .space 8
@@ -1009,6 +1127,7 @@ struct test15_D : test15_NV1, virtual test15_B2 {
// CHECK-LP64-NEXT: .quad __ZN2D14bar4Ev
// CHECK-LP64-NEXT: .quad __ZN2D14bar5Ev
+test16_D d16;
test15_D d15;
test13_D d13;
test11_D d11;
diff --git a/test/SemaCXX/incomplete-call.cpp b/test/SemaCXX/incomplete-call.cpp
index 6134189f0a9a..08bfdefd6247 100644
--- a/test/SemaCXX/incomplete-call.cpp
+++ b/test/SemaCXX/incomplete-call.cpp
@@ -1,5 +1,5 @@
// RUN: clang-cc -fsyntax-only -verify %s
-struct A; // expected-note 13 {{forward declaration of 'struct A'}}
+struct A; // expected-note 14 {{forward declaration of 'struct A'}}
A f(); // expected-note {{note: 'f' declared here}}
@@ -35,4 +35,8 @@ void g() {
b[0]; // expected-error {{calling 'operator[]' with incomplete return type 'struct A'}}
b + 1; // expected-error {{calling 'operator+' with incomplete return type 'struct A'}}
b->f(); // expected-error {{calling 'operator->' with incomplete return type 'struct A'}}
+
+ A (B::*mfp)() = 0;
+ (b.*mfp)(); // expected-error {{calling function with incomplete return type 'struct A'}}
+
}
diff --git a/test/SemaTemplate/explicit-instantiation.cpp b/test/SemaTemplate/explicit-instantiation.cpp
index b9a4ad282b9f..b04639f6e78c 100644
--- a/test/SemaTemplate/explicit-instantiation.cpp
+++ b/test/SemaTemplate/explicit-instantiation.cpp
@@ -14,19 +14,22 @@ struct X0 {
T f0(T x) {
return x + 1; // expected-error{{invalid operands}}
}
- T* f0(T*, T*);
+ T* f0(T*, T*) { return T(); }
template<typename U>
- T f0(T, U);
+ T f0(T, U) { return T(); }
};
+template<typename T>
+T X0<T>::value; // expected-error{{no matching constructor}}
+
template int X0<int>::value;
struct NotDefaultConstructible {
NotDefaultConstructible(int);
};
-template NotDefaultConstructible X0<NotDefaultConstructible>::value;
+template NotDefaultConstructible X0<NotDefaultConstructible>::value; // expected-note{{instantiation}}
template int X0<int>::f0(int);
template int* X0<int>::f0(int*, int*);
@@ -43,11 +46,11 @@ template MemPtr X0<MemPtr>::f0(MemPtr); // expected-note{{requested here}}
struct X2 {
int f0(int); // expected-note{{refers here}}
- template<typename T> T f1(T);
- template<typename T> T* f1(T*);
+ template<typename T> T f1(T) { return T(); }
+ template<typename T> T* f1(T*) { return 0; }
- template<typename T, typename U> void f2(T, U*); // expected-note{{candidate}}
- template<typename T, typename U> void f2(T*, U); // expected-note{{candidate}}
+ template<typename T, typename U> void f2(T, U*) { } // expected-note{{candidate}}
+ template<typename T, typename U> void f2(T*, U) { } // expected-note{{candidate}}
};
template int X2::f0(int); // expected-error{{not an instantiation}}
@@ -57,12 +60,12 @@ template int *X2::f1(int *); // okay
template void X2::f2(int *, int *); // expected-error{{ambiguous}}
-template<typename T> void print_type();
+template<typename T> void print_type() { }
template void print_type<int>();
template void print_type<float>();
-template<typename T> void print_type(T*);
+template<typename T> void print_type(T*) { }
template void print_type(int*);
template void print_type<int>(float*); // expected-error{{does not refer}}
diff --git a/test/SemaTemplate/temp_explicit.cpp b/test/SemaTemplate/temp_explicit.cpp
index 0292964a1a76..9c824d6f4145 100644
--- a/test/SemaTemplate/temp_explicit.cpp
+++ b/test/SemaTemplate/temp_explicit.cpp
@@ -15,7 +15,6 @@ template class N::X1<int>;
template class ::N::X1<int, float>;
using namespace N;
-template class X1<float>;
// Check for some bogus syntax that probably means that the user
// wanted to write an explicit specialization, but forgot the '<>'