summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2009-10-23 14:22:18 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2009-10-23 14:22:18 +0000
commit73490b890977362d28dd6326843a1ecae413921d (patch)
tree3fdd91eae574e32453a4baf462961c742df2691a /test
parenta5f348eb914e67b51914117fac117c18c1f8d650 (diff)
Notes
Diffstat (limited to 'test')
-rw-r--r--test/Analysis/misc-ps-region-store.m69
-rw-r--r--test/Analysis/misc-ps.m34
-rw-r--r--test/Analysis/refcnt_naming.m4
-rw-r--r--test/Analysis/retain-release-region-store.m85
-rw-r--r--test/Analysis/retain-release.m38
-rw-r--r--test/CMakeLists.txt6
-rw-r--r--test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp18
-rw-r--r--test/CXX/temp/temp.spec/p5.cpp29
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp10
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp29
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p1.cpp89
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p2.cpp43
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p3.cpp55
-rw-r--r--test/CXX/temp/temp.spec/temp.explicit/p4.cpp32
-rw-r--r--test/CodeGen/2009-10-20-GlobalDebug.c4
-rw-r--r--test/CodeGen/builtins.c2
-rw-r--r--test/CodeGen/debug-info.c14
-rw-r--r--test/CodeGen/ext-vector-shuffle.c8
-rw-r--r--test/CodeGen/vector.c31
-rw-r--r--test/CodeGenCXX/address-of-fntemplate.cpp13
-rw-r--r--test/CodeGenCXX/call-arg-zero-temp.cpp23
-rw-r--r--test/CodeGenCXX/casts.cpp14
-rw-r--r--test/CodeGenCXX/default-arg-temps.cpp9
-rw-r--r--test/CodeGenCXX/derived-to-base-conv.cpp79
-rw-r--r--test/CodeGenCXX/expr.cpp9
-rw-r--r--test/CodeGenCXX/mangle-subst.cpp5
-rw-r--r--test/CodeGenCXX/member-function-pointers.cpp16
-rw-r--r--test/CodeGenCXX/ptr-to-datamember.cpp70
-rw-r--r--test/CodeGenCXX/references.cpp29
-rw-r--r--test/CodeGenCXX/temporaries.cpp117
-rw-r--r--test/Driver/cxx-pth.cpp12
-rw-r--r--test/Driver/darwin-ld.c2
-rw-r--r--test/Index/c-index-pch.c14
-rw-r--r--test/Index/c-index-pch.h7
-rw-r--r--test/Misc/message-length.c15
-rw-r--r--test/Preprocessor/macro_paste_bcpl_comment.c2
-rw-r--r--test/Sema/attr-noreturn.c6
-rw-r--r--test/Sema/exprs.c9
-rw-r--r--test/Sema/switch.c7
-rw-r--r--test/Sema/vector-assign.c12
-rw-r--r--test/Sema/vector-init.c7
-rw-r--r--test/SemaCXX/abstract.cpp15
-rw-r--r--test/SemaCXX/ambiguous-builtin-unary-operator.cpp18
-rw-r--r--test/SemaCXX/bool.cpp12
-rw-r--r--test/SemaCXX/builtin-ptrtomember-ambig.cpp5
-rw-r--r--test/SemaCXX/builtin-ptrtomember-overload.cpp12
-rw-r--r--test/SemaCXX/exception-spec.cpp3
-rw-r--r--test/SemaCXX/incomplete-call.cpp7
-rw-r--r--test/SemaCXX/member-expr.cpp11
-rw-r--r--test/SemaCXX/overloaded-builtin-operators.cpp25
-rw-r--r--test/SemaCXX/overloaded-operator.cpp2
-rw-r--r--test/SemaCXX/ptrtomember-overload-resolution.cpp44
-rw-r--r--test/SemaCXX/static-cast.cpp11
-rw-r--r--test/SemaCXX/switch.cpp15
-rw-r--r--test/SemaObjC/objc-string-constant.m2
-rw-r--r--test/SemaObjC/try-catch.m2
-rw-r--r--test/SemaTemplate/extern-templates.cpp6
-rw-r--r--test/SemaTemplate/fun-template-def.cpp2
-rw-r--r--test/SemaTemplate/instantiate-expr-2.cpp15
-rw-r--r--test/SemaTemplate/member-access-expr.cpp15
-rw-r--r--test/SemaTemplate/member-template-access-expr.cpp26
-rw-r--r--test/SemaTemplate/variadic-class-template-2.cpp2
62 files changed, 1267 insertions, 60 deletions
diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m
index e849042b3d3d2..b6fff102a7019 100644
--- a/test/Analysis/misc-ps-region-store.m
+++ b/test/Analysis/misc-ps-region-store.m
@@ -141,9 +141,11 @@ again:
}
}
+//===----------------------------------------------------------------------===//
// Reduced test case from <rdar://problem/7114618>.
// Basically a null check is performed on the field value, which is then
// assigned to a variable and then checked again.
+//===----------------------------------------------------------------------===//
struct s_7114618 { int *p; };
void test_rdar_7114618(struct s_7114618 *s) {
if (s->p) {
@@ -168,9 +170,11 @@ void f() {
}
}
+//===----------------------------------------------------------------------===//
// <rdar://problem/7185607>
// Bit-fields of a struct should be invalidated when blasting the entire
// struct with an integer constant.
+//===----------------------------------------------------------------------===//
struct test_7185607 {
int x : 10;
int y : 22;
@@ -181,9 +185,11 @@ int rdar_test_7185607() {
return s.x; // no-warning
}
+//===----------------------------------------------------------------------===//
// <rdar://problem/7242006> [RegionStore] compound literal assignment with
// floats not honored
// This test case is mirrored in misc-ps.m, but this case is a negative.
+//===----------------------------------------------------------------------===//
typedef float CGFloat;
typedef struct _NSSize {
CGFloat width;
@@ -195,9 +201,11 @@ CGFloat rdar7242006_negative(CGFloat x) {
return y.width; // expected-warning{{garbage}}
}
+//===----------------------------------------------------------------------===//
// <rdar://problem/7249340> - Allow binding of values to symbolic regions.
// This test case shows how RegionStore tracks the value bound to 'x'
// after the assignment.
+//===----------------------------------------------------------------------===//
typedef int* ptr_rdar_7249340;
void rdar_7249340(ptr_rdar_7249340 x) {
*x = 1;
@@ -207,11 +215,13 @@ void rdar_7249340(ptr_rdar_7249340 x) {
*p = 0xDEADBEEF; // no-warning
}
+//===----------------------------------------------------------------------===//
// <rdar://problem/7249327> - This test case tests both value tracking of
// array values and that we handle symbolic values that are casted
// between different integer types. Note the assignment 'n = *a++'; here
// 'n' is and 'int' and '*a' is 'unsigned'. Previously we got a false positive
// at 'x += *b++' (undefined value) because we got a false path.
+//===----------------------------------------------------------------------===//
int rdar_7249327_aux(void);
void rdar_7249327(unsigned int A[2*32]) {
@@ -237,8 +247,10 @@ void rdar_7249327(unsigned int A[2*32]) {
x += *b++; // no-warning
}
+//===----------------------------------------------------------------------===//
// <rdar://problem/6914474> - Check that 'x' is invalidated because its
// address is passed in as a value to a struct.
+//===----------------------------------------------------------------------===//
struct doodad_6914474 { int *v; };
extern void prod_6914474(struct doodad_6914474 *d);
int rdar_6914474(void) {
@@ -278,8 +290,11 @@ int test_handle_array_wrapper() {
return p->z; // no-warning
}
+//===----------------------------------------------------------------------===//
// <rdar://problem/7261075> [RegionStore] crash when
// handling load: '*((unsigned int *)"????")'
+//===----------------------------------------------------------------------===//
+
int rdar_7261075(void) {
unsigned int var = 0;
if (var == *((unsigned int *)"????"))
@@ -287,8 +302,11 @@ int rdar_7261075(void) {
return 0;
}
+//===----------------------------------------------------------------------===//
// <rdar://problem/7275774> false path due to limited pointer
// arithmetic constraints
+//===----------------------------------------------------------------------===//
+
void rdar_7275774(void *data, unsigned n) {
if (!(data || n == 0))
return;
@@ -303,3 +321,54 @@ void rdar_7275774(void *data, unsigned n) {
}
}
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7312221>
+//
+// Test that Objective-C instance variables aren't prematurely pruned
+// from the analysis state.
+//===----------------------------------------------------------------------===//
+
+struct rdar_7312221_value { int x; };
+
+@interface RDar7312221
+{
+ struct rdar_7312221_value *y;
+}
+- (void) doSomething_7312221;
+@end
+
+extern struct rdar_7312221_value *rdar_7312221_helper();
+extern int rdar_7312221_helper_2(id o);
+extern void rdar_7312221_helper_3(int z);
+
+@implementation RDar7312221
+- (void) doSomething_7312221 {
+ if (y == 0) {
+ y = rdar_7312221_helper();
+ if (y != 0) {
+ y->x = rdar_7312221_helper_2(self);
+ // The following use of 'y->x' previously triggered a null dereference, as the value of 'y'
+ // before 'y = rdar_7312221_helper()' would be used.
+ rdar_7312221_helper_3(y->x); // no-warning
+ }
+ }
+}
+@end
+
+struct rdar_7312221_container {
+ struct rdar_7312221_value *y;
+};
+
+extern int rdar_7312221_helper_4(struct rdar_7312221_container *s);
+
+// This test case essentially matches the one in [RDar7312221 doSomething_7312221].
+void doSomething_7312221_with_struct(struct rdar_7312221_container *Self) {
+ if (Self->y == 0) {
+ Self->y = rdar_7312221_helper();
+ if (Self->y != 0) {
+ Self->y->x = rdar_7312221_helper_4(Self);
+ rdar_7312221_helper_3(Self->y->x); // no-warning
+ }
+ }
+}
+
diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m
index 10e5823c206ce..fcc13a39a4610 100644
--- a/test/Analysis/misc-ps.m
+++ b/test/Analysis/misc-ps.m
@@ -681,14 +681,40 @@ void *rdar7152418_bar();
return 1;
}
+//===----------------------------------------------------------------------===//
// Test constant-folding of symbolic values, automatically handling type
-// conversions of the symbol as necessary. Previously this would crash
-// once we started eagerly evaluating symbols whose values were constrained
-// to a single value.
-void test_constant_symbol(signed char x) {
+// conversions of the symbol as necessary.
+//===----------------------------------------------------------------------===//
+
+
+// Previously this would crash once we started eagerly evaluating symbols whose
+// values were constrained to a single value.
+void test_symbol_fold_1(signed char x) {
while (1) {
if (x == ((signed char) 0)) {}
}
}
+// This previously caused a crash because it triggered an assertion in APSInt.
+void test_symbol_fold_2(unsigned int * p, unsigned int n,
+ const unsigned int * grumpkin, unsigned int dn) {
+ unsigned int i;
+ unsigned int tempsub[8];
+ unsigned int *solgrumpkin = tempsub + n;
+ for (i = 0; i < n; i++)
+ solgrumpkin[i] = (i < dn) ? ~grumpkin[i] : 0xFFFFFFFF;
+ for (i <<= 5; i < (n << 5); i++) {}
+}
+
+// This previously caused a crash because it triggered an assertion in APSInt.
+// 'x' would evaluate to a 8-bit constant (because of the return value of
+// test_symbol_fold_3_aux()) which would not get properly promoted to an
+// integer.
+char test_symbol_fold_3_aux(void);
+unsigned test_symbol_fold_3(void) {
+ unsigned x = test_symbol_fold_3_aux();
+ if (x == 54)
+ return (x << 8) | 0x5;
+ return 0;
+}
diff --git a/test/Analysis/refcnt_naming.m b/test/Analysis/refcnt_naming.m
index bea404799ba34..2ce00b2a8cca7 100644
--- a/test/Analysis/refcnt_naming.m
+++ b/test/Analysis/refcnt_naming.m
@@ -15,7 +15,7 @@ typedef signed char BOOL;
-(NSObject*)photoCopy; // read as "photo Copy"
-(NSObject*)__blebPRCopy; // read as "bleb PRCopy"
-(NSObject*)__blebPRcopy; // read as "bleb P Rcopy"
--(NSObject*)new_theprefixdoesnotcount; // read as "theprefixdoesnotcount"
+-(NSObject*)new_theprefixdoescount; // read as "new theprefixdoescount"
-(NSObject*)newestAwesomeStuff; // read as "newest awesome stuff"
@end
@@ -49,7 +49,7 @@ void testNames(NamingTest* x) {
[x photoCopy]; // expected-warning{{leak}}
[x __blebPRCopy]; // expected-warning{{leak}}
[x __blebPRcopy]; // no-warning
- [x new_theprefixdoesnotcount]; // no-warning
+ [x new_theprefixdoescount]; // expected-warning{{leak}}
[x newestAwesomeStuff]; // no-warning
}
diff --git a/test/Analysis/retain-release-region-store.m b/test/Analysis/retain-release-region-store.m
index 7a696833f92df..eacac49c81271 100644
--- a/test/Analysis/retain-release-region-store.m
+++ b/test/Analysis/retain-release-region-store.m
@@ -1,5 +1,4 @@
// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -verify %s
-// XFAIL
//===----------------------------------------------------------------------===//
// The following code is reduced using delta-debugging from
@@ -43,14 +42,19 @@ typedef mach_port_name_t mach_port_t;
typedef signed char BOOL;
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
-@protocol NSObject - (BOOL)isEqual:(id)object;
+@protocol NSObject
+- (BOOL)isEqual:(id)object;
- (id)retain;
- (oneway void)release;
@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
-@end @interface NSObject <NSObject> {
-}
-@end typedef float CGFloat;
+@end
+@interface NSObject <NSObject> {}
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+@end
+typedef float CGFloat;
typedef double NSTimeInterval;
@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate;
@end enum {
@@ -74,6 +78,13 @@ kDAReturnSuccess = 0, kDAReturnError = (((0x3e)&0x3f)<<26) | (((0x368)&0xfff
typedef mach_error_t DAReturn;
typedef const struct __DADissenter * DADissenterRef;
extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string );
+@interface NSNumber : NSObject
+- (id)initWithInt:(int)value;
+@end
+typedef unsigned long NSUInteger;
+@interface NSArray : NSObject
+-(id) initWithObjects:(const id *)objects count:(NSUInteger) cnt;
+@end
//===----------------------------------------------------------------------===//
// Test cases.
@@ -116,15 +127,14 @@ CFAbsoluteTime f4() {
}
@end
-//===----------------------------------------------------------------------===//
-// <rdar://problem/7257223> - False positive due to not invalidating the
-// reference count of a tracked region that was itself invalidated.
-//===----------------------------------------------------------------------===//
+//===------------------------------------------------------------------------------------------===//
+// <rdar://problem/7257223> (also <rdar://problem/7283470>) - False positive due to not invalidating
+// the reference count of a tracked region that was itself invalidated.
+//===------------------------------------------------------------------------------------------===//
typedef struct __rdar_7257223 { CFDateRef x; } RDar7257223;
void rdar_7257223_aux(RDar7257223 *p);
-// THIS CASE CURRENTLY FAILS.
CFDateRef rdar7257223_Create(void) {
RDar7257223 s;
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
@@ -140,3 +150,58 @@ CFDateRef rdar7257223_Create_2(void) {
return s.x;
}
+void rdar7283470(void) {
+ NSNumber *numbers[] = {
+ [[NSNumber alloc] initWithInt:1], // no-warning
+ [[NSNumber alloc] initWithInt:2], // no-warning
+ [[NSNumber alloc] initWithInt:3], // no-warning
+ [[NSNumber alloc] initWithInt:4], // no-warning
+ [[NSNumber alloc] initWithInt:5] // no-warning
+ };
+
+ for (unsigned i = 0 ; i < sizeof(numbers) / sizeof(numbers[0]) ; ++i)
+ [numbers[i] release];
+}
+
+void rdar7283470_positive(void) {
+ NSNumber *numbers[] = {
+ [[NSNumber alloc] initWithInt:1], // expected-warning{{leak}}
+ [[NSNumber alloc] initWithInt:2], // expected-warning{{leak}}
+ [[NSNumber alloc] initWithInt:3], // expected-warning{{leak}}
+ [[NSNumber alloc] initWithInt:4], // expected-warning{{leak}}
+ [[NSNumber alloc] initWithInt:5] // expected-warning{{leak}}
+ };
+}
+
+void rdar7283470_2(void) {
+ NSNumber *numbers[] = {
+ [[NSNumber alloc] initWithInt:1], // no-warning
+ [[NSNumber alloc] initWithInt:2], // no-warning
+ [[NSNumber alloc] initWithInt:3], // no-warning
+ [[NSNumber alloc] initWithInt:4], // no-warning
+ [[NSNumber alloc] initWithInt:5] // no-warning
+ };
+
+ NSArray *s_numbers =[[NSArray alloc] initWithObjects:&numbers[0] count:sizeof(numbers) / sizeof(numbers[0])];
+
+ for (unsigned i = 0 ; i < sizeof(numbers) / sizeof(numbers[0]) ; ++i)
+ [numbers[i] release];
+
+ [s_numbers release];
+}
+
+void rdar7283470_2_positive(void) {
+ NSNumber *numbers[] = {
+ [[NSNumber alloc] initWithInt:1], // no-warning
+ [[NSNumber alloc] initWithInt:2], // no-warning
+ [[NSNumber alloc] initWithInt:3], // no-warning
+ [[NSNumber alloc] initWithInt:4], // no-warning
+ [[NSNumber alloc] initWithInt:5] // no-warning
+ };
+
+ NSArray *s_numbers =[[NSArray alloc] initWithObjects: &numbers[0] count:sizeof(numbers) / sizeof(numbers[0])]; // expected-warning{{leak}}
+
+ for (unsigned i = 0 ; i < sizeof(numbers) / sizeof(numbers[0]) ; ++i)
+ [numbers[i] release];
+}
+
diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m
index 7076bb2942542..e620037b2c14f 100644
--- a/test/Analysis/retain-release.m
+++ b/test/Analysis/retain-release.m
@@ -1098,6 +1098,44 @@ CVReturn rdar_7283567_2(CFAllocatorRef allocator, size_t width, size_t height,
}
//===----------------------------------------------------------------------===//
+// <rdar://problem/7265711> allow 'new', 'copy', 'alloc', 'init' prefix to
+// start before '_' when determining Cocoa fundamental rule
+//
+// Previously the retain/release checker just skipped prefixes before the
+// first '_' entirely. Now the checker honors the prefix if it results in a
+// recognizable naming convention (e.g., 'new', 'init').
+//===----------------------------------------------------------------------===//
+
+@interface RDar7265711 {}
+- (id) new_stuff;
+@end
+
+void rdar7265711_a(RDar7265711 *x) {
+ id y = [x new_stuff]; // expected-warning{{leak}}
+}
+
+void rdar7265711_b(RDar7265711 *x) {
+ id y = [x new_stuff]; // no-warning
+ [y release];
+}
+
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7306898> clang thinks [NSCursor dragCopyCursor] returns a
+// retained reference
+//===----------------------------------------------------------------------===//
+
+@interface NSCursor : NSObject
++ (NSCursor *)dragCopyCursor;
+@end
+
+void rdar7306898(void) {
+ // 'dragCopyCursor' does not follow Cocoa's fundamental rule. It is a noun, not an sentence
+ // implying a 'copy' of something.
+ NSCursor *c = [NSCursor dragCopyCursor]; // no-warning
+ NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning{{leak}}
+}
+
+//===----------------------------------------------------------------------===//
// Tests of ownership attributes.
//===----------------------------------------------------------------------===//
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 2a7f132fb5df3..66f05bff69945 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -45,7 +45,7 @@ if(PYTHONINTERP_FOUND)
${LLVM_SOURCE_DIR}/utils/lit/lit.py
-sv ${CLANG_TEST_EXTRA_ARGS}
${CMAKE_CURRENT_BINARY_DIR}/${testdir}
- DEPENDS clang clang-cc index-test
+ DEPENDS clang clang-cc index-test c-index-test
COMMENT "Running Clang regression tests in ${testdir}")
endforeach()
@@ -62,7 +62,7 @@ if(PYTHONINTERP_FOUND)
${LLVM_SOURCE_DIR}/utils/lit/lit.py
-sv ${CLANG_TEST_EXTRA_ARGS}
${CMAKE_CURRENT_BINARY_DIR}
- DEPENDS clang clang-cc index-test
+ DEPENDS clang clang-cc index-test c-index-test
COMMENT "Running Clang regression tests")
add_custom_target(clang-c++tests
@@ -78,6 +78,6 @@ if(PYTHONINTERP_FOUND)
${LLVM_SOURCE_DIR}/utils/lit/lit.py
-sv ${CLANG_TEST_EXTRA_ARGS}
${CMAKE_CURRENT_SOURCE_DIR}/../utils/C++Tests
- DEPENDS clang clang-cc index-test
+ DEPENDS clang clang-cc index-test c-index-test
COMMENT "Running Clang regression tests")
endif()
diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp
new file mode 100644
index 0000000000000..4d0319e58dfbb
--- /dev/null
+++ b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p4.cpp
@@ -0,0 +1,18 @@
+// RUN: clang-cc -fsyntax-only -verify -std=c++98 -pedantic -Werror %s
+int a1[] = { 1, 3, 5 };
+void f() {
+ int a2[] = { 1, 3, 5 };
+}
+template <typename T>
+void tf() {
+ T t;
+ // Element type may be dependent
+ T a3[] = { 1, 3, 5 };
+ // As might be the initializer list, value
+ int a5[] = { sizeof(T) };
+ // or even type.
+ int a6[] = { t.get() };
+}
+
+// Allowed by GNU extension
+int a4[] = {}; // expected-warning {{zero size arrays}}
diff --git a/test/CXX/temp/temp.spec/p5.cpp b/test/CXX/temp/temp.spec/p5.cpp
new file mode 100644
index 0000000000000..d5632e7f341d6
--- /dev/null
+++ b/test/CXX/temp/temp.spec/p5.cpp
@@ -0,0 +1,29 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+template<typename T> inline void f(T) { }
+template void f(int); // expected-note{{previous explicit instantiation}}
+template void f(int); // expected-error{{duplicate explicit instantiation}}
+
+template<typename T>
+struct X0 {
+ union Inner { };
+
+ void f(T) { }
+
+ static T value;
+};
+
+template<typename T>
+T X0<T>::value = 3.14;
+
+template struct X0<int>; // expected-note{{previous explicit instantiation}}
+template struct X0<int>; // expected-error{{duplicate explicit instantiation}}
+
+template void X0<float>::f(float); // expected-note{{previous explicit instantiation}}
+template void X0<float>::f(float); // expected-error{{duplicate explicit instantiation}}
+
+template union X0<float>::Inner; // expected-note{{previous explicit instantiation}}
+template union X0<float>::Inner; // expected-error{{duplicate explicit instantiation}}
+
+template float X0<float>::value; // expected-note{{previous explicit instantiation}}
+template float X0<float>::value; // expected-error{{duplicate explicit instantiation}}
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
new file mode 100644
index 0000000000000..d7731f17637c9
--- /dev/null
+++ b/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp
@@ -0,0 +1,10 @@
+// RUN: clang-cc -fsyntax-only -std=c++0x -verify %s
+
+template<typename T>
+struct X {
+ void f() {}
+};
+
+template inline void X<int>::f(); // expected-error{{'inline'}}
+
+// FIXME: test constexpr
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp
new file mode 100644
index 0000000000000..3938509961b49
--- /dev/null
+++ b/test/CXX/temp/temp.spec/temp.explicit/p1-emit.cpp
@@ -0,0 +1,29 @@
+// RUN: clang-cc -emit-llvm -triple x86_64-apple-darwin10 -o - %s | FileCheck %s
+template<typename T>
+struct X {
+ static T member1;
+ static T member2;
+ static T member3;
+};
+
+template<typename T>
+T X<T>::member1;
+
+template<typename T>
+T X<T>::member2 = 17;
+
+// CHECK: @_ZN1XIiE7member1E = global i32 0
+template int X<int>::member1;
+
+// CHECK: @_ZN1XIiE7member2E = global i32 17
+template int X<int>::member2;
+
+// For implicit instantiation of
+long& get(bool Cond1, bool Cond2) {
+ // CHECK: @_ZN1XIlE7member1E = weak global i64 0
+ // CHECK: @_ZN1XIlE7member2E = weak global i64 17
+ // CHECK: @_ZN1XIlE7member3E = external global i64
+ return Cond1? X<long>::member1
+ : Cond2? X<long>::member2
+ : X<long>::member3;
+}
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p1.cpp b/test/CXX/temp/temp.spec/temp.explicit/p1.cpp
new file mode 100644
index 0000000000000..896e30efb8866
--- /dev/null
+++ b/test/CXX/temp/temp.spec/temp.explicit/p1.cpp
@@ -0,0 +1,89 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+struct C { };
+
+template<typename T>
+struct X0 {
+ T value; // expected-error{{incomplete}}
+};
+
+// Explicitly instantiate a class template specialization
+template struct X0<int>;
+template struct X0<void>; // expected-note{{instantiation}}
+
+// Explicitly instantiate a function template specialization
+template<typename T>
+void f0(T t) {
+ ++t; // expected-error{{cannot modify}}
+}
+
+template void f0(int);
+template void f0<long>(long);
+template void f0<>(unsigned);
+template void f0(int C::*); // expected-note{{instantiation}}
+
+// Explicitly instantiate a member template specialization
+template<typename T>
+struct X1 {
+ template<typename U>
+ struct Inner {
+ T member1;
+ U member2; // expected-error{{incomplete}}
+ };
+
+ template<typename U>
+ void f(T& t, U u) {
+ t = u; // expected-error{{incompatible}}
+ }
+};
+
+template struct X1<int>::Inner<float>;
+template struct X1<int>::Inner<double>;
+template struct X1<int>::Inner<void>; // expected-note{{instantiation}}
+
+template void X1<int>::f(int&, float);
+template void X1<int>::f<long>(int&, long);
+template void X1<int>::f<>(int&, double);
+template void X1<int>::f<>(int&, int*); // expected-note{{instantiation}}
+
+// Explicitly instantiate members of a class template
+struct Incomplete; // expected-note{{forward declaration}}
+struct NonDefaultConstructible {
+ NonDefaultConstructible(int);
+};
+
+template<typename T, typename U>
+struct X2 {
+ void f(T &t, U u) {
+ t = u; // expected-error{{incompatible}}
+ }
+
+ struct Inner {
+ T member1;
+ U member2; // expected-error{{incomplete}}
+ };
+
+ static T static_member1;
+ static U static_member2;
+};
+
+template<typename T, typename U>
+T X2<T, U>::static_member1 = 17; // expected-error{{incompatible type}}
+
+template<typename T, typename U>
+U X2<T, U>::static_member2; // expected-error{{no matching}}
+
+template void X2<int, float>::f(int &, float);
+template void X2<int, float>::f(int &, double); // expected-error{{does not refer}}
+template void X2<int, int*>::f(int&, int*); // expected-note{{instantiation}}
+
+template struct X2<int, float>::Inner;
+template struct X2<int, Incomplete>::Inner; // expected-note{{instantiation}}
+
+template int X2<int, float>::static_member1;
+template int* X2<int*, float>::static_member1; // expected-note{{instantiation}}
+template
+ NonDefaultConstructible X2<NonDefaultConstructible, int>::static_member1;
+
+template
+ NonDefaultConstructible X2<int, NonDefaultConstructible>::static_member2; // expected-note{{instantiation}}
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p2.cpp b/test/CXX/temp/temp.spec/temp.explicit/p2.cpp
new file mode 100644
index 0000000000000..f3d2c955cb5bd
--- /dev/null
+++ b/test/CXX/temp/temp.spec/temp.explicit/p2.cpp
@@ -0,0 +1,43 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// Example from the standard
+template<class T> class Array { void mf() { } };
+
+template class Array<char>;
+template void Array<int>::mf();
+template<class T> void sort(Array<T>& v) { /* ... */ }
+template void sort(Array<char>&);
+namespace N {
+ template<class T> void f(T&) { }
+}
+template void N::f<int>(int&);
+
+
+template<typename T>
+struct X0 {
+ struct Inner {};
+ void f() { }
+ static T value;
+};
+
+template<typename T>
+T X0<T>::value = 17;
+
+typedef X0<int> XInt;
+
+template struct XInt::Inner; // expected-error{{template-id}}
+template void XInt::f(); // expected-error{{template-id}}
+template int XInt::value; // expected-error{{template-id}}
+
+namespace N {
+ template<typename T>
+ struct X1 { // expected-note{{explicit instantiation refers here}}
+ };
+
+ template<typename T>
+ void f1(T) {}; // expected-note{{explicit instantiation refers here}}
+}
+using namespace N;
+
+template struct X1<int>; // expected-error{{must occur in}}
+template void f1(int); // expected-error{{must occur in}}
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p3.cpp b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp
new file mode 100644
index 0000000000000..2bd781bbed284
--- /dev/null
+++ b/test/CXX/temp/temp.spec/temp.explicit/p3.cpp
@@ -0,0 +1,55 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// A declaration of a function template shall be in scope at the point of the
+// explicit instantiation of the function template.
+template<typename T> void f0(T) { }
+template void f0(int); // okay
+
+// A definition of the class or class template containing a member function
+// template shall be in scope at the point of the explicit instantiation of
+// the member function template.
+struct X0; // expected-note 2{{forward declaration}}
+template<typename> struct X1; // expected-note 2{{declared here}} \
+ // expected-note 3{{forward declaration}}
+
+// FIXME: Repeated diagnostics here!
+template void X0::f0<int>(int); // expected-error 2{{incomplete type}} \
+ // expected-error{{invalid token after}}
+template void X1<int>::f0<int>(int); // expected-error{{implicit instantiation of undefined template}} \
+ // expected-error{{incomplete type}} \\
+ // expected-error{{invalid token}}
+
+// A definition of a class template or class member template shall be in scope
+// at the point of the explicit instantiation of the class template or class
+// member template.
+template struct X1<float>; // expected-error{{explicit instantiation of undefined template}}
+
+template<typename T>
+struct X2 { // expected-note 4{{refers here}}
+ template<typename U>
+ struct Inner; // expected-note{{declared here}}
+
+ struct InnerClass; // expected-note{{forward declaration}}
+};
+
+template struct X2<int>::Inner<float>; // expected-error{{explicit instantiation of undefined template}}
+
+// A definition of a class template shall be in scope at the point of an
+// explicit instantiation of a member function or a static data member of the
+// class template.
+template void X1<int>::f1(int); // expected-error{{incomplete type}} \
+ // expected-error{{does not refer}}
+
+template int X1<int>::member; // expected-error{{incomplete type}} \
+ // expected-error{{does not refer}}
+
+// A definition of a member class of a class template shall be in scope at the
+// point of an explicit instantiation of the member class.
+template struct X2<float>::InnerClass; // expected-error{{undefined member}}
+
+// If the declaration of the explicit instantiation names an implicitly-declared
+// special member function (Clause 12), the program is ill-formed.
+template X2<int>::X2(); // expected-error{{not an instantiation}}
+template X2<int>::X2(const X2&); // expected-error{{not an instantiation}}
+template X2<int>::~X2(); // expected-error{{not an instantiation}}
+template X2<int> &X2<int>::operator=(const X2<int>&); // expected-error{{not an instantiation}}
diff --git a/test/CXX/temp/temp.spec/temp.explicit/p4.cpp b/test/CXX/temp/temp.spec/temp.explicit/p4.cpp
new file mode 100644
index 0000000000000..04e511b0b2d5d
--- /dev/null
+++ b/test/CXX/temp/temp.spec/temp.explicit/p4.cpp
@@ -0,0 +1,32 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+template<typename T> void f0(T); // expected-note{{here}}
+template void f0(int); // expected-error{{explicit instantiation of undefined function template}}
+
+template<typename T>
+struct X0 {
+ struct Inner;
+
+ void f1(); // expected-note{{here}}
+
+ static T value; // expected-note{{here}}
+};
+
+template void X0<int>::f1(); // expected-error{{explicit instantiation of undefined member function}}
+
+template int X0<int>::value; // expected-error{{explicit instantiation of undefined static data member}}
+
+template<> void f0(long);
+template void f0(long); // okay
+
+template<> void X0<long>::f1();
+template void X0<long>::f1();
+
+template<> struct X0<long>::Inner;
+template struct X0<long>::Inner;
+
+template<> long X0<long>::value;
+template long X0<long>::value;
+
+template<> struct X0<double>;
+template struct X0<double>;
diff --git a/test/CodeGen/2009-10-20-GlobalDebug.c b/test/CodeGen/2009-10-20-GlobalDebug.c
new file mode 100644
index 0000000000000..eea3fb5307b43
--- /dev/null
+++ b/test/CodeGen/2009-10-20-GlobalDebug.c
@@ -0,0 +1,4 @@
+// RUN: clang -ccc-host-triple i386-apple-darwin10 -S -g -dA %s -o - | FileCheck %s
+int global;
+// CHECK: asciz "global" ## DW_AT_MIPS_linkage_name
+int main() { return 0;}
diff --git a/test/CodeGen/builtins.c b/test/CodeGen/builtins.c
index ac59b274958a3..359d5070ccc1e 100644
--- a/test/CodeGen/builtins.c
+++ b/test/CodeGen/builtins.c
@@ -117,7 +117,7 @@ int main() {
-char *strcat(char *a, char const *b) {}
+void strcat() {}
void foo() {
__builtin_strcat(0, 0);
diff --git a/test/CodeGen/debug-info.c b/test/CodeGen/debug-info.c
index beee7ac9b61a3..85ad988bc2162 100644
--- a/test/CodeGen/debug-info.c
+++ b/test/CodeGen/debug-info.c
@@ -1,10 +1,12 @@
-// RUN: clang-cc -o %t --emit-llvm -g %s
+// RUN: clang-cc -o %t --emit-llvm -g %s &&
+// RUN: FileCheck --input-file=%t %s
// PR3023
void convert(void) {
struct { typeof(0) f0; } v0;
}
+
// PR2784
struct OPAQUE;
typedef struct OPAQUE *PTR;
@@ -19,9 +21,11 @@ struct s0 *f0(struct s0 *a0) {
return a0->p;
}
+
// PR3134
char xpto[];
+
// PR3427
struct foo {
int a;
@@ -29,9 +33,17 @@ struct foo {
};
struct foo bar;
+
// PR4143
struct foo2 {
enum bar *bar;
};
struct foo2 foo2;
+
+
+// Radar 7325611
+// CHECK: "barfoo"
+typedef int barfoo;
+barfoo foo() {
+}
diff --git a/test/CodeGen/ext-vector-shuffle.c b/test/CodeGen/ext-vector-shuffle.c
index f53db945da03f..7655515964011 100644
--- a/test/CodeGen/ext-vector-shuffle.c
+++ b/test/CodeGen/ext-vector-shuffle.c
@@ -1,6 +1,6 @@
-// RUN: clang-cc %s -emit-llvm -o - | not grep 'extractelement' &&
-// RUN: clang-cc %s -emit-llvm -o - | not grep 'insertelement' &&
-// RUN: clang-cc %s -emit-llvm -o - | grep 'shufflevector'
+// RUN: clang-cc %s -x cl -emit-llvm -o - | not grep 'extractelement' &&
+// RUN: clang-cc %s -x cl -emit-llvm -o - | not grep 'insertelement' &&
+// RUN: clang-cc %s -x cl -emit-llvm -o - | grep 'shufflevector'
typedef __attribute__(( ext_vector_type(2) )) float float2;
typedef __attribute__(( ext_vector_type(4) )) float float4;
@@ -13,3 +13,5 @@ float4 test2(float4 V) {
float2 W = V.ww;
return W.xyxy + W.yxyx;
}
+
+float4 test3(float4 V1, float4 V2) { return (float4)(V1.zw, V2.xy); }
diff --git a/test/CodeGen/vector.c b/test/CodeGen/vector.c
index 5e48fd42b1d07..2945ebaa4d058 100644
--- a/test/CodeGen/vector.c
+++ b/test/CodeGen/vector.c
@@ -1,7 +1,7 @@
-// RUN: clang-cc -emit-llvm %s -o -
+// RUN: clang-cc -triple i386-apple-darwin9 -mcpu=pentium4 -g -emit-llvm %s -o -
typedef short __v4hi __attribute__ ((__vector_size__ (8)));
-void f() {
+void test1() {
__v4hi A = (__v4hi)0LL;
}
@@ -9,11 +9,34 @@ __v4hi x = {1,2,3};
__v4hi y = {1,2,3,4};
typedef int vty __attribute((vector_size(16)));
-int a() { vty b; return b[2LL]; }
+int test2() { vty b; return b[2LL]; }
// PR4339
typedef float vec4 __attribute__((vector_size(16)));
-void vac ( vec4* a, char b, float c ) {
+void test3 ( vec4* a, char b, float c ) {
(*a)[b] = c;
}
+
+
+
+
+#include <mmintrin.h>
+
+int test4(int argc, char *argv[]) {
+ int array[16] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
+ __m64 *p = (__m64 *)array;
+
+ __m64 accum = _mm_setzero_si64();
+
+ for (int i=0; i<8; ++i)
+ accum = _mm_add_pi32(p[i], accum);
+
+ __m64 accum2 = _mm_unpackhi_pi32(accum, accum);
+ accum = _mm_add_pi32(accum, accum2);
+
+ int result = _mm_cvtsi64_si32(accum);
+ _mm_empty();
+
+ return result;
+}
diff --git a/test/CodeGenCXX/address-of-fntemplate.cpp b/test/CodeGenCXX/address-of-fntemplate.cpp
new file mode 100644
index 0000000000000..1f0c8f38630b8
--- /dev/null
+++ b/test/CodeGenCXX/address-of-fntemplate.cpp
@@ -0,0 +1,13 @@
+// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s
+template <typename T> void f(T) {}
+template <typename T> void f() { }
+
+void test() {
+ // CHECK: @_Z1fIiEvT_
+ void (*p)(int) = &f;
+
+ // CHECK: @_Z1fIiEvv
+ void (*p2)() = f<int>;
+}
+// CHECK: define linkonce_odr void @_Z1fIiEvT_
+// CHECK: define linkonce_odr void @_Z1fIiEvv
diff --git a/test/CodeGenCXX/call-arg-zero-temp.cpp b/test/CodeGenCXX/call-arg-zero-temp.cpp
new file mode 100644
index 0000000000000..2c44f69d975e8
--- /dev/null
+++ b/test/CodeGenCXX/call-arg-zero-temp.cpp
@@ -0,0 +1,23 @@
+// RUN: clang-cc -triple x86_64-apple-darwin -S %s -o %t-64.s &&
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s &&
+// RUN: clang-cc -triple i386-apple-darwin -S %s -o %t-32.s &&
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s &&
+// RUN: true
+
+
+extern "C" int printf(...);
+
+struct obj{ int a; float b; double d; };
+
+void foo(obj o) {
+ printf("%d %f %f\n", o.a, o.b, o.d);
+}
+
+int main() {
+ obj o = obj();
+ foo(obj());
+}
+
+// CHECK-LP64: call __Z3foo3obj
+
+// CHECK-LP32: call __Z3foo3obj
diff --git a/test/CodeGenCXX/casts.cpp b/test/CodeGenCXX/casts.cpp
new file mode 100644
index 0000000000000..045f2d4fe031c
--- /dev/null
+++ b/test/CodeGenCXX/casts.cpp
@@ -0,0 +1,14 @@
+// RUN: clang-cc %s -emit-llvm -o %t
+
+// PR5248
+namespace PR5248 {
+struct A {
+ void copyFrom(const A &src);
+ void addRef(void);
+};
+
+void A::copyFrom(const A &src) {
+ ((A &)src).addRef();
+}
+}
+
diff --git a/test/CodeGenCXX/default-arg-temps.cpp b/test/CodeGenCXX/default-arg-temps.cpp
index 2651446669b8a..8385aff6291c7 100644
--- a/test/CodeGenCXX/default-arg-temps.cpp
+++ b/test/CodeGenCXX/default-arg-temps.cpp
@@ -15,7 +15,7 @@ public:
void g() {
// RUN: grep "call void @_ZN1TC1Ev" %t | count 4 &&
- // RUN: grep "call void @_ZN1TD1Ev" %t | count 4
+ // RUN: grep "call void @_ZN1TD1Ev" %t | count 4 &&
f();
f();
@@ -23,3 +23,10 @@ void g() {
X b(a);
X c = a;
}
+
+
+// RUN: grep memset %t
+class obj{ int a; float b; double d; };
+void h() {
+ obj o = obj();
+}
diff --git a/test/CodeGenCXX/derived-to-base-conv.cpp b/test/CodeGenCXX/derived-to-base-conv.cpp
new file mode 100644
index 0000000000000..0c890195119f9
--- /dev/null
+++ b/test/CodeGenCXX/derived-to-base-conv.cpp
@@ -0,0 +1,79 @@
+// RUN: clang-cc -triple x86_64-apple-darwin -std=c++0x -S %s -o %t-64.s &&
+// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s &&
+// RUN: clang-cc -triple i386-apple-darwin -std=c++0x -S %s -o %t-32.s &&
+// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s &&
+// RUN: true
+
+extern "C" int printf(...);
+extern "C" void exit(int);
+
+struct A {
+ A (const A&) { printf("A::A(const A&)\n"); }
+ A() {};
+};
+
+struct B : public A {
+ B() {};
+};
+
+struct C : public B {
+ C() {};
+};
+
+struct X {
+ operator B&() {printf("X::operator B&()\n"); return b; }
+ operator C&() {printf("X::operator C&()\n"); return c; }
+ X (const X&) { printf("X::X(const X&)\n"); }
+ X () { printf("X::X()\n"); }
+ B b;
+ C c;
+};
+
+void f(A) {
+ printf("f(A)\n");
+}
+
+
+void func(X x)
+{
+ f (x);
+}
+
+int main()
+{
+ X x;
+ func(x);
+}
+
+struct Base;
+
+struct Root {
+ operator Base&() { exit(1); }
+};
+
+struct Derived;
+
+struct Base : Root {
+ Base(const Base&) { printf("Base::(const Base&)\n"); }
+ Base() { printf("Base::Base()\n"); }
+ operator Derived&() { exit(1); }
+};
+
+struct Derived : Base {
+};
+
+void foo(Base) {}
+
+void test(Derived bb)
+{
+ // CHECK-LP64-NOT: call __ZN4BasecvR7DerivedEv
+ // CHECK-LP32-NOT: call L__ZN4BasecvR7DerivedEv
+ foo(bb);
+}
+// CHECK-LP64: call __ZN1XcvR1BEv
+// CHECK-LP64: call __ZN1AC1ERKS_
+
+// CHECK-LP32: call L__ZN1XcvR1BEv
+// CHECK-LP32: call L__ZN1AC1ERKS_
+
+
diff --git a/test/CodeGenCXX/expr.cpp b/test/CodeGenCXX/expr.cpp
index ae5b0e644f277..4dc97c47aa265 100644
--- a/test/CodeGenCXX/expr.cpp
+++ b/test/CodeGenCXX/expr.cpp
@@ -1,5 +1,12 @@
// RUN: clang-cc -emit-llvm -x c++ < %s
-void f(int x) {
+void test0(int x) {
if (x != 0) return;
}
+
+
+// PR5211
+void test1() {
+ char *xpto;
+ while ( true && xpto[0] );
+}
diff --git a/test/CodeGenCXX/mangle-subst.cpp b/test/CodeGenCXX/mangle-subst.cpp
index c53a6300aa19c..46a21b62b515d 100644
--- a/test/CodeGenCXX/mangle-subst.cpp
+++ b/test/CodeGenCXX/mangle-subst.cpp
@@ -54,3 +54,8 @@ template<typename T> void ft3(S1<T>, S1<char>) { }
// CHECK: @_ZN2NS3ft3IiEEvNS_2S1IT_EENS1_IcEE
template void ft3<int>(S1<int>, S1<char>);
}
+
+// PR5196
+// CHECK: @_Z1fPKcS0_
+void f(const char*, const char*) {}
+
diff --git a/test/CodeGenCXX/member-function-pointers.cpp b/test/CodeGenCXX/member-function-pointers.cpp
index 13f7de5a631bc..a7c21133d0513 100644
--- a/test/CodeGenCXX/member-function-pointers.cpp
+++ b/test/CodeGenCXX/member-function-pointers.cpp
@@ -71,3 +71,19 @@ namespace PR5177 {
void bar(B1 b2) { while (b2()) ; }
}
+
+// PR5138
+namespace PR5138 {
+ struct foo {
+ virtual void bar(foo *);
+ };
+
+ extern "C" {
+ void baz(foo *);
+ }
+
+ void (foo::*ptr1)(void *) = (void (foo::*)(void *))&foo::bar;
+ void (*ptr2)(void *) = (void (*)(void *))&baz;
+
+ void (foo::*ptr3)(void) = (void (foo::*)(void))&foo::bar;
+}
diff --git a/test/CodeGenCXX/ptr-to-datamember.cpp b/test/CodeGenCXX/ptr-to-datamember.cpp
new file mode 100644
index 0000000000000..eee03c060f91c
--- /dev/null
+++ b/test/CodeGenCXX/ptr-to-datamember.cpp
@@ -0,0 +1,70 @@
+// RUN: clang-cc -emit-llvm -o - %s
+
+extern "C" int printf(...);
+
+struct F {
+ F() : iF(1), fF(2.0) {}
+ int iF;
+ float fF;
+};
+
+struct V {
+ double d;
+ int iV;
+};
+
+struct B : virtual V{
+ double d;
+ int iB;
+};
+
+struct B1 : virtual V{
+ double d;
+ int iB1;
+};
+
+class A : public B, public B1 {
+public:
+ A() : f(1.0), d(2.0), Ai(3) {}
+ float f;
+ double d;
+ int Ai;
+ F Af;
+};
+
+void pr(const F& b) {
+ printf(" %d %f\n", b.iF, b.fF);
+}
+
+void test_aggr_pdata(A& a1) {
+ F A::* af = &A::Af;
+ pr(a1.*af);
+
+ (a1.*af).iF = 100;
+ (a1.*af).fF = 200.00;
+ printf(" %d %f\n", (a1.*af).iF, (a1.*af).fF);
+ pr(a1.*af);
+
+ (a1.*af).iF++;
+ (a1.*af).fF--;
+ --(a1.*af).fF;
+ pr(a1.*af);
+}
+
+int main()
+{
+ A a1;
+ int A::* pa = &A::Ai;
+ float A::* pf = &A::f;
+ double A::* pd = &A::d;
+ printf("%d %d %d\n", &A::Ai, &A::f, &A::d);
+ printf("%d\n", &A::B::iB);
+ printf("%d\n", &A::B1::iB1);
+ printf("%d\n", &A::f);
+ printf("%d\n", &A::B::iV);
+ printf("%d\n", &A::B1::iV);
+ printf("%d\n", &A::B::V::iV);
+ printf("%d\n", &A::B1::V::iV);
+ printf("%d, %f, %f \n", a1.*pa, a1.*pf, a1.*pd);
+ test_aggr_pdata(a1);
+}
diff --git a/test/CodeGenCXX/references.cpp b/test/CodeGenCXX/references.cpp
index 32d46b3e104b3..8e0e1cbe84e83 100644
--- a/test/CodeGenCXX/references.cpp
+++ b/test/CodeGenCXX/references.cpp
@@ -107,3 +107,32 @@ void h() {
const C& c = D();
}
+namespace T {
+ struct A {
+ A();
+ ~A();
+ };
+
+ struct B {
+ B();
+ ~B();
+ A f();
+ };
+
+ void f() {
+ // CHECK: call void @_ZN1T1BC1Ev
+ // CHECK: call void @_ZN1T1B1fEv
+ // CHECK: call void @_ZN1T1BD1Ev
+ const A& a = B().f();
+ // CHECK: call void @_ZN1T1fEv
+ f();
+ // CHECK: call void @_ZN1T1AD1Ev
+ }
+}
+
+// PR5227.
+namespace PR5227 {
+void f(int &a) {
+ (a = 10) = 20;
+}
+}
diff --git a/test/CodeGenCXX/temporaries.cpp b/test/CodeGenCXX/temporaries.cpp
new file mode 100644
index 0000000000000..d622193f59866
--- /dev/null
+++ b/test/CodeGenCXX/temporaries.cpp
@@ -0,0 +1,117 @@
+// RUN: clang-cc -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s
+struct A {
+ A();
+ ~A();
+ void f();
+};
+
+void f1() {
+ // CHECK: call void @_ZN1AC1Ev
+ // CHECK: call void @_ZN1AD1Ev
+ (void)A();
+
+ // CHECK: call void @_ZN1AC1Ev
+ // CHECK: call void @_ZN1AD1Ev
+ A().f();
+}
+
+// Function calls
+struct B {
+ B();
+ ~B();
+};
+
+B g();
+
+void f2() {
+ // CHECK-NOT: call void @_ZN1BC1Ev
+ // CHECK: call void @_ZN1BD1Ev
+ (void)g();
+}
+
+// Member function calls
+struct C {
+ C();
+ ~C();
+
+ C f();
+};
+
+void f3() {
+ // CHECK: call void @_ZN1CC1Ev
+ // CHECK: call void @_ZN1CD1Ev
+ // CHECK: call void @_ZN1CD1Ev
+ C().f();
+}
+
+// Function call operator
+struct D {
+ D();
+ ~D();
+
+ D operator()();
+};
+
+void f4() {
+ // CHECK call void @_ZN1DC1Ev
+ // CHECK call void @_ZN1DD1Ev
+ // CHECK call void @_ZN1DD1Ev
+ D()();
+}
+
+// Overloaded operators
+struct E {
+ E();
+ ~E();
+ E operator+(const E&);
+ E operator!();
+};
+
+void f5() {
+ // CHECK: call void @_ZN1EC1Ev
+ // CHECK: call void @_ZN1EC1Ev
+ // CHECK: call void @_ZN1ED1Ev
+ // CHECK: call void @_ZN1ED1Ev
+ // CHECK: call void @_ZN1ED1Ev
+ E() + E();
+
+ // CHECK: call void @_ZN1EC1Ev
+ // CHECK: call void @_ZN1ED1Ev
+ // CHECK: call void @_ZN1ED1Ev
+ !E();
+}
+
+struct F {
+ F();
+ ~F();
+ F& f();
+};
+
+void f6() {
+ // CHECK: call void @_ZN1FC1Ev
+ // CHECK: call void @_ZN1FD1Ev
+ F().f();
+}
+
+struct G {
+ G();
+ G(A);
+ ~G();
+ operator A();
+};
+
+void a(const A&);
+
+void f7() {
+ // CHECK: call void @_ZN1AC1Ev
+ // CHECK: call void @_Z1aRK1A
+ // CHECK: call void @_ZN1AD1Ev
+ a(A());
+
+ // CHECK: call void @_ZN1GC1Ev
+ // CHECK: call void @_ZN1Gcv1AEv
+ // CHECK: call void @_Z1aRK1A
+ // CHECK: call void @_ZN1AD1Ev
+ // CHECK: call void @_ZN1GD1Ev
+ a(G());
+}
diff --git a/test/Driver/cxx-pth.cpp b/test/Driver/cxx-pth.cpp
new file mode 100644
index 0000000000000..a06a25753869d
--- /dev/null
+++ b/test/Driver/cxx-pth.cpp
@@ -0,0 +1,12 @@
+// Test forced PTH for CXX support.
+
+// RUN: clang -x c++-header %s -### 2> %t.log &&
+// RUN: FileCheck -check-prefix EMIT -input-file %t.log %s &&
+
+// EMIT: "{{.*}}/clang-cc{{.*}}" {{.*}} "-emit-pth" "{{.*}}.cpp.gch" "-x" "c++-header" "{{.*}}.cpp"
+
+// RUN: touch %t.h.gch &&
+// RUN: clang -E -include %t.h %s -### 2> %t.log &&
+// RUN: FileCheck -check-prefix USE -input-file %t.log %s
+
+// USE: "{{.*}}/clang-cc{{.*}}" {{.*}}"-include-pth" "{{.*}}.h.gch" {{.*}}"-x" "c++" "{{.*}}.cpp"
diff --git a/test/Driver/darwin-ld.c b/test/Driver/darwin-ld.c
index d81605bbe93d1..9165a4a9011f5 100644
--- a/test/Driver/darwin-ld.c
+++ b/test/Driver/darwin-ld.c
@@ -33,7 +33,7 @@
// Note that at conception, this exactly matches gcc.
// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -A ARG0 -F ARG1 -L ARG2 -Mach -T ARG4 -X -Z -all_load -allowable_client ARG8 -bind_at_load -compatibility_version ARG11 -current_version ARG12 -d -dead_strip -dylib_file ARG14 -dylinker -dylinker_install_name ARG16 -dynamic -dynamiclib -e ARG19 -exported_symbols_list ARG20 -fexceptions -flat_namespace -fnested-functions -fopenmp -force_cpusubtype_ALL -fpie -fprofile-arcs -headerpad_max_install_names -image_base ARG29 -init ARG30 -install_name ARG31 -m ARG33 -miphoneos-version-min=2.0 -mmacosx-version-min=10.3.2 -multi_module -multiply_defined ARG37 -multiply_defined_unused ARG38 -no_dead_strip_inits_and_terms -nodefaultlibs -nofixprebinding -nomultidefs -noprebind -noseglinkedit -nostartfiles -nostdlib -pagezero_size ARG54 -pg -prebind -prebind_all_twolevel_modules -preload -r -read_only_relocs ARG55 -s -sectalign ARG57_0 ARG57_1 ARG57_2 -sectcreate ARG58_0 ARG58_1 ARG58_2 -sectobjectsymbols ARG59_0 ARG59_1 -sectorder ARG60_0 ARG60_1 ARG60_2 -seg1addr ARG61 -seg_addr_table ARG62 -seg_addr_table_filename ARG63 -segaddr ARG64_0 ARG64_1 -segcreate ARG65_0 ARG65_1 ARG65_2 -seglinkedit -segprot ARG67_0 ARG67_1 ARG67_2 -segs_read_FOO -segs_read_only_addr ARG69 -segs_read_write_addr ARG70 -shared-libgcc -single_module -static -static-libgcc -sub_library ARG77 -sub_umbrella ARG78 -t -twolevel_namespace -twolevel_namespace_hints -u ARG82 -umbrella ARG83 -undefined ARG84 -unexported_symbols_list ARG85 -w -weak_reference_mismatches ARG87 -whatsloaded -whyload -y -filelist FOO 2> %t.log &&
-// RUN: grep '".*ld.*" "-static" "-dylib" "-dylib_compatibility_version" "ARG11" "-dylib_current_version" "ARG12" "-arch" "i386" "-dylib_install_name" "ARG31" "-all_load" "-allowable_client" "ARG8" "-bind_at_load" "-dead_strip" "-no_dead_strip_inits_and_terms" "-dylib_file" "ARG14" "-dynamic" "-exported_symbols_list" "ARG20" "-flat_namespace" "-headerpad_max_install_names" "-image_base" "ARG29" "-init" "ARG30" "-macosx_version_min" "10.3.2" "-iphoneos_version_min" "2.0" "-nomultidefs" "-multi_module" "-single_module" "-multiply_defined" "ARG37" "-multiply_defined_unused" "ARG38" "-pie" "-prebind" "-noprebind" "-nofixprebinding" "-prebind_all_twolevel_modules" "-read_only_relocs" "ARG55" "-sectcreate" "ARG58_0" "ARG58_1" "ARG58_2" "-sectorder" "ARG60_0" "ARG60_1" "ARG60_2" "-seg1addr" "ARG61" "-segprot" "ARG67_0" "ARG67_1" "ARG67_2" "-segaddr" "ARG64_0" "ARG64_1" "-segs_read_only_addr" "ARG69" "-segs_read_write_addr" "ARG70" "-seg_addr_table" "ARG62" "-seg_addr_table_filename" "ARG63" "-sub_library" "ARG77" "-sub_umbrella" "ARG78" "-twolevel_namespace" "-twolevel_namespace_hints" "-umbrella" "ARG83" "-undefined" "ARG84" "-unexported_symbols_list" "ARG85" "-weak_reference_mismatches" "ARG87" "-X" "-y" "-w" "-pagezero_size" "ARG54" "-segs_read_FOO" "-seglinkedit" "-noseglinkedit" "-sectalign" "ARG57_0" "ARG57_1" "ARG57_2" "-sectobjectsymbols" "ARG59_0" "ARG59_1" "-segcreate" "ARG65_0" "ARG65_1" "ARG65_2" "-whyload" "-whatsloaded" "-dylinker_install_name" "ARG16" "-dylinker" "-Mach" "-d" "-s" "-t" "-Z" "-u" "ARG82" "-undefined" "ARG84" "-A" "ARG0" "-e" "ARG19" "-m" "ARG33" "-r" "-o" "a.out" "-L" "ARG2" "-lgomp" "-L/usr/lib/i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1/../../../i686-apple-darwin9/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin9/4.2.1/../../.." "-filelist" "FOO" "-lgcov" "-allow_stack_execute" "-T" "ARG4" "-F" "ARG1"' %t.log &&
+// RUN: grep '".*ld.*" "-static" "-dylib" "-dylib_compatibility_version" "ARG11" "-dylib_current_version" "ARG12" "-arch" "i386" "-dylib_install_name" "ARG31" "-all_load" "-allowable_client" "ARG8" "-bind_at_load" "-dead_strip" "-no_dead_strip_inits_and_terms" "-dylib_file" "ARG14" "-dynamic" "-exported_symbols_list" "ARG20" "-flat_namespace" "-headerpad_max_install_names" "-image_base" "ARG29" "-init" "ARG30" "-macosx_version_min" "10.3.2" "-iphoneos_version_min" "2.0" "-nomultidefs" "-multi_module" "-single_module" "-multiply_defined" "ARG37" "-multiply_defined_unused" "ARG38" "-pie" "-prebind" "-noprebind" "-nofixprebinding" "-prebind_all_twolevel_modules" "-read_only_relocs" "ARG55" "-sectcreate" "ARG58_0" "ARG58_1" "ARG58_2" "-sectorder" "ARG60_0" "ARG60_1" "ARG60_2" "-seg1addr" "ARG61" "-segprot" "ARG67_0" "ARG67_1" "ARG67_2" "-segaddr" "ARG64_0" "ARG64_1" "-segs_read_only_addr" "ARG69" "-segs_read_write_addr" "ARG70" "-seg_addr_table" "ARG62" "-seg_addr_table_filename" "ARG63" "-sub_library" "ARG77" "-sub_umbrella" "ARG78" "-twolevel_namespace" "-twolevel_namespace_hints" "-umbrella" "ARG83" "-undefined" "ARG84" "-unexported_symbols_list" "ARG85" "-weak_reference_mismatches" "ARG87" "-X" "-y" "-w" "-pagezero_size" "ARG54" "-segs_read_FOO" "-seglinkedit" "-noseglinkedit" "-sectalign" "ARG57_0" "ARG57_1" "ARG57_2" "-sectobjectsymbols" "ARG59_0" "ARG59_1" "-segcreate" "ARG65_0" "ARG65_1" "ARG65_2" "-whyload" "-whatsloaded" "-dylinker_install_name" "ARG16" "-dylinker" "-Mach" "-d" "-s" "-t" "-Z" "-u" "ARG82" "-undefined" "ARG84" "-A" "ARG0" "-e" "ARG19" "-m" "ARG33" "-r" "-o" "a.out" "-L" "ARG2" "-lgomp" "-L/usr/lib/i686-apple-darwin.*/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin.*/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin.*/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin.*/4.2.1/../../../i686-apple-darwin.*/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin.*/4.2.1/../../.." "-filelist" "FOO" "-lgcov" "-allow_stack_execute" "-T" "ARG4" "-F" "ARG1"' %t.log &&
// Don't run dsymutil on a fat build of an executable.
// RUN: clang -ccc-host-triple i386-apple-darwin9 -### -arch i386 -arch x86_64 -g %s 2> %t.log &&
diff --git a/test/Index/c-index-pch.c b/test/Index/c-index-pch.c
new file mode 100644
index 0000000000000..aae4eb3669fc0
--- /dev/null
+++ b/test/Index/c-index-pch.c
@@ -0,0 +1,14 @@
+// RUN: clang-cc -emit-pch -x c -o %t.pch %S/c-index-pch.h &&
+// RUN: clang-cc -include-pch %t.pch -x c -emit-pch -o %t.ast %s &&
+// RUN: c-index-test %t.ast all | FileCheck -check-prefix=ALL %s &&
+// RUN: c-index-test %t.ast local | FileCheck -check-prefix=LOCAL %s
+// ALL: FunctionDecl=foo
+// ALL: VarDecl=bar
+// ALL: FunctionDecl=wibble
+// ALL: FunctionDecl=wonka
+// LOCAL-NOT: FunctionDecl=foo
+// LOCAL-NOT: VarDecl=bar
+// LOCAL: FunctionDecl=wibble
+// LOCAL: FunctionDecl=wonka
+void wibble(int i);
+void wonka(float);
diff --git a/test/Index/c-index-pch.h b/test/Index/c-index-pch.h
new file mode 100644
index 0000000000000..6dda18000c2f6
--- /dev/null
+++ b/test/Index/c-index-pch.h
@@ -0,0 +1,7 @@
+#ifndef C_INDEX_PCH_H
+#define C_INDEX_PCH_H
+
+void foo(int i, float f);
+extern int bar;
+
+#endif // C_INDEX_PCH_H
diff --git a/test/Misc/message-length.c b/test/Misc/message-length.c
index ac5dab99ca524..9f4d66fe71c02 100644
--- a/test/Misc/message-length.c
+++ b/test/Misc/message-length.c
@@ -1,14 +1,7 @@
-// RUN: clang -fsyntax-only -fmessage-length=72 %s 2> %t &&
-
-// RUN: grep -A4 "FILE:23" %t > %t.msg &&
-// FIXME: This diagnostic is getting truncated very poorly.
-// RUN: grep -e '^ ...// some long comment text and a brace, eh {} ' %t.msg &&
-// RUN: grep -e '^ \^' %t.msg &&
-// RUN: clang -fsyntax-only -fmessage-length=1 %s &&
-// RUN: true
+// RUN: clang -fsyntax-only -fmessage-length=72 %s 2>&1 | FileCheck -strict-whitespace %s &&
+// RUN: clang -fsyntax-only -fmessage-length=1 %s
// Hack so we can check things better, force the file name and line.
-
# 1 "FILE" 1
/* It's tough to verify the results of this test mechanically, since
@@ -33,3 +26,7 @@ void a_very_long_line(int *ip, float *FloatPointer) {
}
#pragma STDC CX_LIMITED_RANGE // some long comment text and a brace, eh {}
+
+
+// CHECK: FILE:23:78
+// CHECK: {{^ ...// some long comment text and a brace, eh {} $}}
diff --git a/test/Preprocessor/macro_paste_bcpl_comment.c b/test/Preprocessor/macro_paste_bcpl_comment.c
index 8bbee5dc2dd95..0637a87217395 100644
--- a/test/Preprocessor/macro_paste_bcpl_comment.c
+++ b/test/Preprocessor/macro_paste_bcpl_comment.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc %s -Eonly 2>&1 | grep error
+// RUN: clang-cc %s -Eonly -fms-extensions=0 2>&1 | grep error
#define COMM1 / ## /
COMM1
diff --git a/test/Sema/attr-noreturn.c b/test/Sema/attr-noreturn.c
index b83eb94e0582b..14011bedca1ae 100644
--- a/test/Sema/attr-noreturn.c
+++ b/test/Sema/attr-noreturn.c
@@ -15,14 +15,14 @@ int f2() __attribute__((noreturn(1, 2))); // expected-error {{attribute requires
void f3() __attribute__((noreturn));
void f3() {
- return; // expected-error {{function 'f3' declared 'noreturn' should not return}}
+ return; // expected-warning {{function 'f3' declared 'noreturn' should not return}}
}
-#pragma clang diagnostic warning "-Winvalid-noreturn"
+#pragma clang diagnostic error "-Winvalid-noreturn"
void f4() __attribute__((noreturn));
void f4() {
- return; // expected-warning {{function 'f4' declared 'noreturn' should not return}}
+ return; // expected-error {{function 'f4' declared 'noreturn' should not return}}
}
// PR4685
diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c
index 69a2320397fda..2bcc0f8a2ca0d 100644
--- a/test/Sema/exprs.c
+++ b/test/Sema/exprs.c
@@ -103,3 +103,12 @@ void test14() {
__m64 mask = (__m64)((__v4hi)a > (__v4hi)a);
}
+
+// PR5242
+typedef unsigned long *test15_t;
+
+test15_t test15(void) {
+ return (test15_t)0 + (test15_t)0; // expected-error {{invalid operands to binary expression ('test15_t' (aka 'unsigned long *') and 'test15_t')}}
+}
+
+
diff --git a/test/Sema/switch.c b/test/Sema/switch.c
index 5999f342aefab..122947e7ce5cd 100644
--- a/test/Sema/switch.c
+++ b/test/Sema/switch.c
@@ -68,3 +68,10 @@ void test5(int z) {
}
}
+void test6() {
+ const char ch = 'a';
+ switch(ch) {
+ case 1234: // expected-warning {{overflow converting case value}}
+ break;
+ }
+}
diff --git a/test/Sema/vector-assign.c b/test/Sema/vector-assign.c
index 5162e1a41c211..bf9c7f37ca6dc 100644
--- a/test/Sema/vector-assign.c
+++ b/test/Sema/vector-assign.c
@@ -5,7 +5,7 @@ typedef signed int v1s __attribute__ ((vector_size (4)));
typedef float v2f __attribute__ ((vector_size(8)));
typedef signed short v4ss __attribute__ ((vector_size (8)));
-void f() {
+void test1() {
v2s v1;
v2u v2;
v1s v3;
@@ -39,7 +39,15 @@ void f() {
}
// PR2263
-float f2(__attribute__((vector_size(16))) float a, int b) {
+float test2(__attribute__((vector_size(16))) float a, int b) {
return a[b];
}
+// PR4838
+typedef long long __attribute__((__vector_size__(2 * sizeof(long long))))
+longlongvec;
+
+void test3a(longlongvec *);
+void test3(const unsigned *src) {
+ test3a(src); // expected-warning {{incompatible pointer types passing 'unsigned int const *', expected 'longlongvec *'}}
+}
diff --git a/test/Sema/vector-init.c b/test/Sema/vector-init.c
index 6eab32425adf1..18104d871d6c2 100644
--- a/test/Sema/vector-init.c
+++ b/test/Sema/vector-init.c
@@ -21,3 +21,10 @@ float4 array3[2] = { {1.0, 2.0, 3.0}, 5.0, 6.0, 7.0, 8.0,
__attribute__((vector_size(16))) // expected-error {{unsupported type 'float (void)' for vector_size attribute, please use on typedef}}
float f1(void) {
}
+
+
+
+// PR5265
+typedef float __attribute__((ext_vector_type (3))) float3;
+int test2[(sizeof(float3) == sizeof(float4))*2-1];
+
diff --git a/test/SemaCXX/abstract.cpp b/test/SemaCXX/abstract.cpp
index e14304a26fe3d..42b8d7febe655 100644
--- a/test/SemaCXX/abstract.cpp
+++ b/test/SemaCXX/abstract.cpp
@@ -123,3 +123,18 @@ struct K {
struct L : public K {
void f();
};
+
+// PR5222
+namespace PR5222 {
+ struct A {
+ virtual A *clone() = 0;
+ };
+ struct B : public A {
+ virtual B *clone() = 0;
+ };
+ struct C : public B {
+ virtual C *clone();
+ };
+
+ C c;
+}
diff --git a/test/SemaCXX/ambiguous-builtin-unary-operator.cpp b/test/SemaCXX/ambiguous-builtin-unary-operator.cpp
index 042546af69024..5affd19a2fdf0 100644
--- a/test/SemaCXX/ambiguous-builtin-unary-operator.cpp
+++ b/test/SemaCXX/ambiguous-builtin-unary-operator.cpp
@@ -2,17 +2,33 @@
struct A {
operator int&();
+ operator long*& ();
};
struct B {
operator long&();
+ operator int*& ();
};
struct C : B, A { };
void test(C c) {
++c; // expected-error {{use of overloaded operator '++' is ambiguous}}\
- // expected-note 4 {{built-in candidate operator ++ (}}
+ // expected-note {{built-in candidate operator++(int &)}} \
+ // expected-note {{built-in candidate operator++(long &)}} \
+ // expected-note {{built-in candidate operator++(long *&)}} \
+ // expected-note {{built-in candidate operator++(int *&)}}
}
+struct A1 { operator volatile int&(); };
+
+struct B1 { operator volatile long&(); };
+
+struct C1 : B1, A1 { };
+
+void test(C1 c) {
+ ++c; // expected-error {{use of overloaded operator '++' is ambiguous}} \
+ // expected-note {{built-in candidate operator++(int volatile &)}} \
+ // expected-note {{built-in candidate operator++(long volatile &)}}
+}
diff --git a/test/SemaCXX/bool.cpp b/test/SemaCXX/bool.cpp
index bc44c73d8cace..259c09c6cb833 100644
--- a/test/SemaCXX/bool.cpp
+++ b/test/SemaCXX/bool.cpp
@@ -16,3 +16,15 @@ void test(bool b)
bool *b1 = (int *)0; // expected-error{{expected 'bool *'}}
}
+
+// static_assert_arg_is_bool(x) compiles only if x is a bool.
+template <typename T>
+void static_assert_arg_is_bool(T x) {
+ bool* p = &x;
+}
+
+void test2() {
+ int n = 2;
+ static_assert_arg_is_bool(n && 4);
+ static_assert_arg_is_bool(n || 5);
+}
diff --git a/test/SemaCXX/builtin-ptrtomember-ambig.cpp b/test/SemaCXX/builtin-ptrtomember-ambig.cpp
index 7e20af35394b8..1b52651910d95 100644
--- a/test/SemaCXX/builtin-ptrtomember-ambig.cpp
+++ b/test/SemaCXX/builtin-ptrtomember-ambig.cpp
@@ -19,6 +19,9 @@ struct C : B {
void foo(C c, int A::* pmf) {
// FIXME. Why so many built-in candidates?
int i = c->*pmf; // expected-error {{use of overloaded operator '->*' is ambiguous}} \
- // expected-note 40 {{built-in candidate operator ->* ('struct A}}
+ // expected-note {{built-in candidate operator->*(struct A const *, int const struct A::*)}} \
+ // expected-note {{built-in candidate operator->*(struct A const *, int struct A::*)}} \
+ // expected-note {{built-in candidate operator->*(struct A *, int const struct A::*)}} \
+ // expected-note {{built-in candidate operator->*(struct A *, int struct A::*)}}
}
diff --git a/test/SemaCXX/builtin-ptrtomember-overload.cpp b/test/SemaCXX/builtin-ptrtomember-overload.cpp
index 718e981805aa6..ed52d47f2cda7 100644
--- a/test/SemaCXX/builtin-ptrtomember-overload.cpp
+++ b/test/SemaCXX/builtin-ptrtomember-overload.cpp
@@ -16,3 +16,15 @@ void foo(C c, B b, int A::* pmf) {
int i = b->*pmf;
}
+struct D {
+ operator const D *();
+};
+
+struct DPtr {
+ operator volatile int D::*();
+};
+
+int test(D d, DPtr dptr) {
+ return d->*dptr;
+}
+
diff --git a/test/SemaCXX/exception-spec.cpp b/test/SemaCXX/exception-spec.cpp
index 9b2a07d796543..56cc435f7db3a 100644
--- a/test/SemaCXX/exception-spec.cpp
+++ b/test/SemaCXX/exception-spec.cpp
@@ -185,3 +185,6 @@ void mfnptr()
template <typename T> struct TEx; // expected-note {{template is declared here}}
void tf() throw(TEx<int>); // expected-error {{implicit instantiation of undefined template}}
+
+// DR 437, class throws itself. FIXME: See Sema::CheckSpecifiedExceptionType.
+//struct DR437 { void f() throw(DR437); };
diff --git a/test/SemaCXX/incomplete-call.cpp b/test/SemaCXX/incomplete-call.cpp
index 08bfdefd62478..3ce898a76f2cc 100644
--- a/test/SemaCXX/incomplete-call.cpp
+++ b/test/SemaCXX/incomplete-call.cpp
@@ -40,3 +40,10 @@ void g() {
(b.*mfp)(); // expected-error {{calling function with incomplete return type 'struct A'}}
}
+
+
+struct C; // expected-note{{forward declaration}}
+
+void test_incomplete_object_call(C& c) {
+ c(); // expected-error{{incomplete type in call to object of type}}
+}
diff --git a/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp
index 28b1224d8d8fb..069f52605b92e 100644
--- a/test/SemaCXX/member-expr.cpp
+++ b/test/SemaCXX/member-expr.cpp
@@ -31,3 +31,14 @@ int f0(B *b) {
return b->f0->f0; // expected-error{{member reference base type 'struct A *()' is not a structure or union}} \
// expected-note{{perhaps you meant to call this function}}
}
+
+int i;
+
+namespace C {
+ int i;
+}
+
+void test2(X *xp) {
+ xp->::i = 7; // expected-error{{qualified member access refers to a member in the global namespace}}
+ xp->C::i = 7; // expected-error{{qualified member access refers to a member in namespace 'C'}}
+}
diff --git a/test/SemaCXX/overloaded-builtin-operators.cpp b/test/SemaCXX/overloaded-builtin-operators.cpp
index 0284b2929b3c0..13777daf2d20b 100644
--- a/test/SemaCXX/overloaded-builtin-operators.cpp
+++ b/test/SemaCXX/overloaded-builtin-operators.cpp
@@ -150,3 +150,28 @@ void test_with_ptrs(VolatileIntPtr vip, ConstIntPtr cip, ShortRef sr,
void test_assign_restrictions(ShortRef& sr) {
sr = (short)0; // expected-error{{no viable overloaded '='}}
}
+
+struct Base { };
+struct Derived1 : Base { };
+struct Derived2 : Base { };
+
+template<typename T>
+struct ConvertibleToPtrOf {
+ operator T*();
+};
+
+bool test_with_base_ptrs(ConvertibleToPtrOf<Derived1> d1,
+ ConvertibleToPtrOf<Derived2> d2) {
+ return d1 == d2; // expected-error{{invalid operands}}
+}
+
+// DR425
+struct A {
+ template< typename T > operator T() const;
+};
+
+void test_dr425(A a) {
+ // FIXME: lots of candidates here!
+ (void)(1.0f * a); // expected-error{{ambiguous}} \
+ // expected-note 81{{candidate}}
+}
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp
index 8f71ad5381382..10b0f5a76804f 100644
--- a/test/SemaCXX/overloaded-operator.cpp
+++ b/test/SemaCXX/overloaded-operator.cpp
@@ -155,7 +155,7 @@ typedef INTREF Func1(FLOAT, double);
typedef float& Func2(int, double);
struct ConvertToFunc {
- operator Func1*(); // expected-note{{conversion candidate of type 'INTREF (*)(float, double)'}}
+ operator Func1*(); // expected-note{{conversion candidate of type 'INTREF (*)(FLOAT, double)'}}
operator Func2&(); // expected-note{{conversion candidate of type 'float &(&)(int, double)'}}
void operator()();
};
diff --git a/test/SemaCXX/ptrtomember-overload-resolution.cpp b/test/SemaCXX/ptrtomember-overload-resolution.cpp
new file mode 100644
index 0000000000000..b3b65ce840cbf
--- /dev/null
+++ b/test/SemaCXX/ptrtomember-overload-resolution.cpp
@@ -0,0 +1,44 @@
+// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x
+
+// 13.3.3.2 Ranking implicit conversion sequences
+// conversion of A::* to B::* is better than conversion of A::* to C::*,
+struct A {
+int Ai;
+};
+
+struct B : public A {};
+struct C : public B {};
+
+const char * f(int C::*){ return ""; }
+int f(int B::*) { return 1; }
+
+struct D : public C {};
+
+const char * g(int B::*){ return ""; }
+int g(int D::*) { return 1; }
+
+void test()
+{
+ int i = f(&A::Ai);
+
+ const char * str = g(&A::Ai);
+}
+
+// conversion of B::* to C::* is better than conversion of A::* to C::*
+typedef void (A::*pmfa)();
+typedef void (B::*pmfb)();
+typedef void (C::*pmfc)();
+
+struct X {
+ operator pmfa();
+ operator pmfb();
+};
+
+
+void g(pmfc);
+
+void test2(X x)
+{
+ g(x);
+}
+
diff --git a/test/SemaCXX/static-cast.cpp b/test/SemaCXX/static-cast.cpp
index 8db8e33b93ce1..d816c05e3ee37 100644
--- a/test/SemaCXX/static-cast.cpp
+++ b/test/SemaCXX/static-cast.cpp
@@ -133,3 +133,14 @@ void t_529_9()
(void)static_cast<int A::*>((int H::*)0); // expected-error {{ambiguous conversion from pointer to member of derived class 'struct H'}}
(void)static_cast<int A::*>((int F::*)0); // expected-error {{conversion from pointer to member of class 'struct F'}}
}
+
+// PR 5261 - static_cast should instantiate template if possible
+namespace pr5261 {
+ struct base {};
+ template<typename E> struct derived : public base {};
+ template<typename E> struct outer {
+ base *pb;
+ ~outer() { (void)static_cast<derived<E>*>(pb); }
+ };
+ outer<int> EntryList;
+}
diff --git a/test/SemaCXX/switch.cpp b/test/SemaCXX/switch.cpp
new file mode 100644
index 0000000000000..b22adb749576a
--- /dev/null
+++ b/test/SemaCXX/switch.cpp
@@ -0,0 +1,15 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+void test() {
+ bool x = true;
+ switch (x) { // expected-warning {{bool}}
+ case 0:
+ break;
+ }
+
+ int n = 3;
+ switch (n && 1) { // expected-warning {{bool}}
+ case 1:
+ break;
+ }
+}
diff --git a/test/SemaObjC/objc-string-constant.m b/test/SemaObjC/objc-string-constant.m
index 98239229a2c7f..d27a46a96632a 100644
--- a/test/SemaObjC/objc-string-constant.m
+++ b/test/SemaObjC/objc-string-constant.m
@@ -29,7 +29,7 @@
@end
@implementation Subclass
-- (NSString *)token;
+- (NSString *)token; // expected-warning {{semicolon before method body is ignored}}
{
NSMutableString *result = nil;
diff --git a/test/SemaObjC/try-catch.m b/test/SemaObjC/try-catch.m
index 076eff5429684..453d80fd59965 100644
--- a/test/SemaObjC/try-catch.m
+++ b/test/SemaObjC/try-catch.m
@@ -30,7 +30,7 @@ typedef struct _NSZone NSZone;
@end
@implementation XCRefactoringTransformation
-- (NSDictionary *)setUpInfoForTransformKey:(NSString *)transformKey outError:(NSError **)outError; {
+- (NSDictionary *)setUpInfoForTransformKey:(NSString *)transformKey outError:(NSError **)outError {
@try {}
// the exception name is optional (weird)
@catch (NSException *) {}
diff --git a/test/SemaTemplate/extern-templates.cpp b/test/SemaTemplate/extern-templates.cpp
index 28fda1a11e6bb..44728d188a24b 100644
--- a/test/SemaTemplate/extern-templates.cpp
+++ b/test/SemaTemplate/extern-templates.cpp
@@ -29,16 +29,14 @@ void test_intptr(X0<int*> xi, X0<int*>::Inner xii) {
xii.g(0);
}
-// FIXME: we would like the notes to point to the explicit instantiation at the
-// bottom.
-extern template class X0<long*>; // expected-note 2{{instantiation}}
+extern template class X0<long*>;
void test_longptr(X0<long*> xl, X0<long*>::Inner xli) {
xl.f(0);
xli.g(0);
}
-template class X0<long*>;
+template class X0<long*>; // expected-note 2{{instantiation}}
template<typename T>
class X1 {
diff --git a/test/SemaTemplate/fun-template-def.cpp b/test/SemaTemplate/fun-template-def.cpp
index dee4250078985..4d8aaa8d16f1e 100644
--- a/test/SemaTemplate/fun-template-def.cpp
+++ b/test/SemaTemplate/fun-template-def.cpp
@@ -35,7 +35,7 @@ T f1(T t1, U u1, int i1)
dynamic_cast<U>(const_cast<T>(i1)))));
new U(i1, t1);
- new int(t1, u1); // expected-error {{initializer of a builtin type can only take one argument}}
+ new int(t1, u1);
new (t1, u1) int;
delete t1;
diff --git a/test/SemaTemplate/instantiate-expr-2.cpp b/test/SemaTemplate/instantiate-expr-2.cpp
index 146e63c5bb00c..194593ac4006e 100644
--- a/test/SemaTemplate/instantiate-expr-2.cpp
+++ b/test/SemaTemplate/instantiate-expr-2.cpp
@@ -178,3 +178,18 @@ namespace N10 {
template class A<int>;
}
+
+namespace N12 {
+ // PR5224
+ template<typename T>
+ struct A { typedef int t0; };
+
+ struct C {
+ C(int);
+
+ template<typename T>
+ static C *f0(T a0) {return new C((typename A<T>::t0) 1); }
+ };
+
+ void f0(int **a) { C::f0(a); }
+}
diff --git a/test/SemaTemplate/member-access-expr.cpp b/test/SemaTemplate/member-access-expr.cpp
index f4922e8ff5208..0a6a6bc0990e5 100644
--- a/test/SemaTemplate/member-access-expr.cpp
+++ b/test/SemaTemplate/member-access-expr.cpp
@@ -74,4 +74,17 @@ void test_destruct(X2 *x2p, int *ip) {
destruct(x2p);
destruct(ip);
destruct_intptr<int>(ip);
-} \ No newline at end of file
+}
+
+// PR5220
+class X3 {
+protected:
+ template <int> float* &f0();
+ template <int> const float* &f0() const;
+ void f1() {
+ (void)static_cast<float*>(f0<0>());
+ }
+ void f1() const{
+ (void)f0<0>();
+ }
+};
diff --git a/test/SemaTemplate/member-template-access-expr.cpp b/test/SemaTemplate/member-template-access-expr.cpp
index 20437aee39dc3..0f9f21f339d1c 100644
--- a/test/SemaTemplate/member-template-access-expr.cpp
+++ b/test/SemaTemplate/member-template-access-expr.cpp
@@ -24,7 +24,29 @@ struct XDerived : public X {
};
void test_f1(XDerived xd) {
- // FIXME: Not quite functional yet.
-// int &ir = f1<X>(xd);
+ int &ir = f1<X>(xd);
}
+// PR5213
+template <class T>
+struct A {};
+
+template<class T>
+class B
+{
+ A<T> a_;
+
+public:
+ void destroy();
+};
+
+template<class T>
+void
+B<T>::destroy()
+{
+ a_.~A<T>();
+}
+
+void do_destroy_B(B<int> b) {
+ b.destroy();
+}
diff --git a/test/SemaTemplate/variadic-class-template-2.cpp b/test/SemaTemplate/variadic-class-template-2.cpp
index eadea901c7fef..b1ac71b88bda4 100644
--- a/test/SemaTemplate/variadic-class-template-2.cpp
+++ b/test/SemaTemplate/variadic-class-template-2.cpp
@@ -14,6 +14,6 @@ template struct TS2<int, int>;
template <typename = int, typename ...> struct TS3 {}; // expected-note{{template parameter is declared here}}
template struct TS3<>; // expected-note{{previous explicit instantiation is here}}
-template struct TS3<int>; // expected-error{{duplicate explicit instantiation of 'TS3<>'}}
+template struct TS3<int>; // expected-error{{duplicate explicit instantiation of 'TS3}}
template struct TS3<int, int>;
template struct TS3<10>; // expected-error{{template argument for template type parameter must be a type}}