summaryrefslogtreecommitdiffstats
path: root/test/SemaObjCXX
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaObjCXX')
-rw-r--r--test/SemaObjCXX/arc-0x.mm32
-rw-r--r--test/SemaObjCXX/arc-templates.mm17
-rw-r--r--test/SemaObjCXX/arc-type-traits.mm126
-rw-r--r--test/SemaObjCXX/arc-unbridged-cast.mm8
-rw-r--r--test/SemaObjCXX/boxing-illegal-types.mm58
-rw-r--r--test/SemaObjCXX/crash.mm23
-rw-r--r--test/SemaObjCXX/delay-parsing-cfunctions.mm48
-rw-r--r--test/SemaObjCXX/delay-parsing-cplusfuncs.mm52
-rw-r--r--test/SemaObjCXX/delay-parsing-func-tryblock.mm66
-rw-r--r--test/SemaObjCXX/exceptions-fragile.mm2
-rw-r--r--test/SemaObjCXX/foreach.mm61
-rw-r--r--test/SemaObjCXX/fragile-abi-object-assign.m2
-rw-r--r--test/SemaObjCXX/instantiate-stmt.mm8
-rw-r--r--test/SemaObjCXX/message.mm2
-rw-r--r--test/SemaObjCXX/objc-container-subscripting.mm4
-rw-r--r--test/SemaObjCXX/property-synthesis-error.mm13
-rw-r--r--test/SemaObjCXX/protocol-lookup.mm2
-rw-r--r--test/SemaObjCXX/warn-missing-super.mm19
18 files changed, 526 insertions, 17 deletions
diff --git a/test/SemaObjCXX/arc-0x.mm b/test/SemaObjCXX/arc-0x.mm
index 28eec51..e24b960 100644
--- a/test/SemaObjCXX/arc-0x.mm
+++ b/test/SemaObjCXX/arc-0x.mm
@@ -11,6 +11,9 @@ void move_it(__strong id &&from) {
- init;
@end
+// <rdar://problem/12031870>: don't warn about this
+extern "C" A* MakeA();
+
// Ensure that deduction works with lifetime qualifiers.
void deduction(id obj) {
auto a = [[A alloc] init];
@@ -22,7 +25,7 @@ void deduction(id obj) {
__strong id *idp = new auto(obj);
__strong id array[17];
- for (auto x : array) {
+ for (auto x : array) { // expected-warning{{'auto' deduced as 'id' in declaration of 'x'}}
__strong id *xPtr = &x;
}
@@ -51,3 +54,30 @@ void test1c() {
(void) ^{ (void) p; };
(void) ^{ (void) v; }; // expected-error {{cannot capture __autoreleasing variable in a block}}
}
+
+
+// <rdar://problem/11319689>
+// warn when initializing an 'auto' variable with an 'id' initializer expression
+
+void testAutoId(id obj) {
+ auto x = obj; // expected-warning{{'auto' deduced as 'id' in declaration of 'x'}}
+}
+
+@interface Array
++ (instancetype)new;
+- (id)objectAtIndex:(int)index;
+@end
+
+// ...but don't warn if it's coming from a template parameter.
+template<typename T, int N>
+void autoTemplateFunction(T param, id obj, Array *arr) {
+ auto x = param; // no-warning
+ auto y = obj; // expected-warning{{'auto' deduced as 'id' in declaration of 'y'}}
+ auto z = [arr objectAtIndex:N]; // expected-warning{{'auto' deduced as 'id' in declaration of 'z'}}
+}
+
+void testAutoIdTemplate(id obj) {
+ autoTemplateFunction<id, 2>(obj, obj, [Array new]); // no-warning
+}
+
+
diff --git a/test/SemaObjCXX/arc-templates.mm b/test/SemaObjCXX/arc-templates.mm
index 9eca846..8009272 100644
--- a/test/SemaObjCXX/arc-templates.mm
+++ b/test/SemaObjCXX/arc-templates.mm
@@ -3,6 +3,8 @@
@interface A
@end
+@class NSString;
+
template<typename T, typename U>
struct is_same {
static const bool value = false;
@@ -266,3 +268,18 @@ namespace rdar9828157 {
float &fr = (f)(ap);
}
}
+
+namespace rdar10862386 {
+ // More deduction with lifetime qualifiers.
+ template <typename T>
+ int testing(const T &) {
+ return 1;
+ }
+
+ void test() {
+ testing(1);
+ testing("hi");
+ testing<NSString *>(@"hi");
+ testing(@"hi");
+ }
+}
diff --git a/test/SemaObjCXX/arc-type-traits.mm b/test/SemaObjCXX/arc-type-traits.mm
index 9877870..67bab00 100644
--- a/test/SemaObjCXX/arc-type-traits.mm
+++ b/test/SemaObjCXX/arc-type-traits.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -std=c++11 %s
// Check the results of the various type-trait query functions on
// lifetime-qualified types in ARC.
@@ -9,48 +9,75 @@
#define TRAIT_IS_TRUE(Trait, Type) char JOIN2(Trait,__LINE__)[Trait(Type)? 1 : -1]
#define TRAIT_IS_FALSE(Trait, Type) char JOIN2(Trait,__LINE__)[Trait(Type)? -1 : 1]
+#define TRAIT_IS_TRUE_2(Trait, Type1, Type2) char JOIN2(Trait,__LINE__)[Trait(Type1, Type2)? 1 : -1]
+#define TRAIT_IS_FALSE_2(Trait, Type1, Type2) char JOIN2(Trait,__LINE__)[Trait(Type1, Type2)? -1 : 1]
+struct HasStrong { id obj; };
+struct HasWeak { __weak id obj; };
+struct HasUnsafeUnretained { __unsafe_unretained id obj; };
+
// __has_nothrow_assign
TRAIT_IS_TRUE(__has_nothrow_assign, __strong id);
TRAIT_IS_TRUE(__has_nothrow_assign, __weak id);
TRAIT_IS_TRUE(__has_nothrow_assign, __autoreleasing id);
TRAIT_IS_TRUE(__has_nothrow_assign, __unsafe_unretained id);
+TRAIT_IS_TRUE(__has_nothrow_assign, HasStrong);
+TRAIT_IS_TRUE(__has_nothrow_assign, HasWeak);
+TRAIT_IS_TRUE(__has_nothrow_assign, HasUnsafeUnretained);
// __has_nothrow_copy
TRAIT_IS_TRUE(__has_nothrow_copy, __strong id);
TRAIT_IS_TRUE(__has_nothrow_copy, __weak id);
TRAIT_IS_TRUE(__has_nothrow_copy, __autoreleasing id);
TRAIT_IS_TRUE(__has_nothrow_copy, __unsafe_unretained id);
+TRAIT_IS_TRUE(__has_nothrow_copy, HasStrong);
+TRAIT_IS_TRUE(__has_nothrow_copy, HasWeak);
+TRAIT_IS_TRUE(__has_nothrow_copy, HasUnsafeUnretained);
// __has_nothrow_constructor
TRAIT_IS_TRUE(__has_nothrow_constructor, __strong id);
TRAIT_IS_TRUE(__has_nothrow_constructor, __weak id);
TRAIT_IS_TRUE(__has_nothrow_constructor, __autoreleasing id);
TRAIT_IS_TRUE(__has_nothrow_constructor, __unsafe_unretained id);
+TRAIT_IS_TRUE(__has_nothrow_constructor, HasStrong);
+TRAIT_IS_TRUE(__has_nothrow_constructor, HasWeak);
+TRAIT_IS_TRUE(__has_nothrow_constructor, HasUnsafeUnretained);
// __has_trivial_assign
TRAIT_IS_FALSE(__has_trivial_assign, __strong id);
TRAIT_IS_FALSE(__has_trivial_assign, __weak id);
TRAIT_IS_FALSE(__has_trivial_assign, __autoreleasing id);
TRAIT_IS_TRUE(__has_trivial_assign, __unsafe_unretained id);
+TRAIT_IS_FALSE(__has_trivial_assign, HasStrong);
+TRAIT_IS_FALSE(__has_trivial_assign, HasWeak);
+TRAIT_IS_TRUE(__has_trivial_assign, HasUnsafeUnretained);
// __has_trivial_copy
TRAIT_IS_FALSE(__has_trivial_copy, __strong id);
TRAIT_IS_FALSE(__has_trivial_copy, __weak id);
TRAIT_IS_FALSE(__has_trivial_copy, __autoreleasing id);
TRAIT_IS_TRUE(__has_trivial_copy, __unsafe_unretained id);
+TRAIT_IS_FALSE(__has_trivial_copy, HasStrong);
+TRAIT_IS_FALSE(__has_trivial_copy, HasWeak);
+TRAIT_IS_TRUE(__has_trivial_copy, HasUnsafeUnretained);
// __has_trivial_constructor
TRAIT_IS_FALSE(__has_trivial_constructor, __strong id);
TRAIT_IS_FALSE(__has_trivial_constructor, __weak id);
TRAIT_IS_FALSE(__has_trivial_constructor, __autoreleasing id);
TRAIT_IS_TRUE(__has_trivial_constructor, __unsafe_unretained id);
+TRAIT_IS_FALSE(__has_trivial_constructor, HasStrong);
+TRAIT_IS_FALSE(__has_trivial_constructor, HasWeak);
+TRAIT_IS_TRUE(__has_trivial_constructor, HasUnsafeUnretained);
// __has_trivial_destructor
TRAIT_IS_FALSE(__has_trivial_destructor, __strong id);
TRAIT_IS_FALSE(__has_trivial_destructor, __weak id);
TRAIT_IS_TRUE(__has_trivial_destructor, __autoreleasing id);
TRAIT_IS_TRUE(__has_trivial_destructor, __unsafe_unretained id);
+TRAIT_IS_FALSE(__has_trivial_destructor, HasStrong);
+TRAIT_IS_FALSE(__has_trivial_destructor, HasWeak);
+TRAIT_IS_TRUE(__has_trivial_destructor, HasUnsafeUnretained);
// __is_literal
TRAIT_IS_TRUE(__is_literal, __strong id);
@@ -69,12 +96,18 @@ TRAIT_IS_FALSE(__is_pod, __strong id);
TRAIT_IS_FALSE(__is_pod, __weak id);
TRAIT_IS_FALSE(__is_pod, __autoreleasing id);
TRAIT_IS_TRUE(__is_pod, __unsafe_unretained id);
+TRAIT_IS_FALSE(__is_pod, HasStrong);
+TRAIT_IS_FALSE(__is_pod, HasWeak);
+TRAIT_IS_TRUE(__is_pod, HasUnsafeUnretained);
// __is_trivial
TRAIT_IS_FALSE(__is_trivial, __strong id);
TRAIT_IS_FALSE(__is_trivial, __weak id);
TRAIT_IS_FALSE(__is_trivial, __autoreleasing id);
TRAIT_IS_TRUE(__is_trivial, __unsafe_unretained id);
+TRAIT_IS_FALSE(__is_trivial, HasStrong);
+TRAIT_IS_FALSE(__is_trivial, HasWeak);
+TRAIT_IS_TRUE(__is_trivial, HasUnsafeUnretained);
// __is_scalar
TRAIT_IS_FALSE(__is_scalar, __strong id);
@@ -88,3 +121,94 @@ TRAIT_IS_TRUE(__is_standard_layout, __weak id);
TRAIT_IS_TRUE(__is_standard_layout, __autoreleasing id);
TRAIT_IS_TRUE(__is_standard_layout, __unsafe_unretained id);
+// __is_trivally_assignable
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __strong id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __weak id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __autoreleasing id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __unsafe_unretained id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __strong id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __weak id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __autoreleasing id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __unsafe_unretained id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __strong id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __weak id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __autoreleasing id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __unsafe_unretained id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __strong id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __weak id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __autoreleasing id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __unsafe_unretained id&&);
+
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __strong id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __weak id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __autoreleasing id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __unsafe_unretained id);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __strong id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __weak id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __autoreleasing id&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __unsafe_unretained id&&);
+
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __strong id);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __weak id);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __autoreleasing id);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __unsafe_unretained id);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __strong id&&);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __weak id&&);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __autoreleasing id&&);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __unsafe_unretained id&&);
+
+TRAIT_IS_FALSE_2(__is_trivially_assignable, HasStrong&, HasStrong);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, HasStrong&, HasStrong&&);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, HasWeak&, HasWeak);
+TRAIT_IS_FALSE_2(__is_trivially_assignable, HasWeak&, HasWeak&&);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, HasUnsafeUnretained&, HasUnsafeUnretained);
+TRAIT_IS_TRUE_2(__is_trivially_assignable, HasUnsafeUnretained&, HasUnsafeUnretained&&);
+
+// __is_trivally_constructible
+TRAIT_IS_FALSE(__is_trivially_constructible, __strong id);
+TRAIT_IS_FALSE(__is_trivially_constructible, __weak id);
+TRAIT_IS_FALSE(__is_trivially_constructible, __autoreleasing id);
+TRAIT_IS_TRUE(__is_trivially_constructible, __unsafe_unretained id);
+
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __strong id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __weak id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __autoreleasing id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __unsafe_unretained id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __strong id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __weak id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __autoreleasing id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __unsafe_unretained id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __strong id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __weak id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __autoreleasing id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __unsafe_unretained id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __strong id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __weak id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __autoreleasing id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __unsafe_unretained id&&);
+
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __strong id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __weak id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __autoreleasing id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __unsafe_unretained id);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __strong id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __weak id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __autoreleasing id&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __unsafe_unretained id&&);
+
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __strong id);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __weak id);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __autoreleasing id);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __unsafe_unretained id);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __strong id&&);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __weak id&&);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __autoreleasing id&&);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __unsafe_unretained id&&);
+
+TRAIT_IS_FALSE_2(__is_trivially_constructible, HasStrong, HasStrong);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, HasStrong, HasStrong&&);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, HasWeak, HasWeak);
+TRAIT_IS_FALSE_2(__is_trivially_constructible, HasWeak, HasWeak&&);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained);
+TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained&&);
+
diff --git a/test/SemaObjCXX/arc-unbridged-cast.mm b/test/SemaObjCXX/arc-unbridged-cast.mm
index 0b3ba07..f7d2391 100644
--- a/test/SemaObjCXX/arc-unbridged-cast.mm
+++ b/test/SemaObjCXX/arc-unbridged-cast.mm
@@ -44,10 +44,10 @@ void test1(int cond) {
x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
- x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
- x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
- x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
- x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
+ x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}}
x = (id) [object property];
x = (id) (cond ? [object property] : (void*) 0);
diff --git a/test/SemaObjCXX/boxing-illegal-types.mm b/test/SemaObjCXX/boxing-illegal-types.mm
new file mode 100644
index 0000000..7729753
--- /dev/null
+++ b/test/SemaObjCXX/boxing-illegal-types.mm
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wattributes %s
+
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+typedef signed char BOOL;
+
+@interface NSNumber
+@end
+@interface NSNumber (NSNumberCreation)
++ (NSNumber *)numberWithChar:(char)value;
++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
++ (NSNumber *)numberWithShort:(short)value;
++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
++ (NSNumber *)numberWithInt:(int)value;
++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
++ (NSNumber *)numberWithLong:(long)value;
++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
++ (NSNumber *)numberWithLongLong:(long long)value;
++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
++ (NSNumber *)numberWithFloat:(float)value;
++ (NSNumber *)numberWithDouble:(double)value;
++ (NSNumber *)numberWithBool:(BOOL)value;
++ (NSNumber *)numberWithInteger:(NSInteger)value;
++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value;
+@end
+
+typedef struct {
+ int x, y, z;
+} point;
+
+void testStruct() {
+ point p = { 0, 0, 0 };
+ id boxed = @(p); // expected-error {{illegal type 'point' used in a boxed expression}}
+}
+
+void testPointers() {
+ void *null = 0;
+ id boxed_null = @(null); // expected-error {{illegal type 'void *' used in a boxed expression}}
+ int numbers[] = { 0, 1, 2 };
+ id boxed_numbers = @(numbers); // expected-error {{illegal type 'int *' used in a boxed expression}}
+}
+
+void testInvalid() {
+ @(not_defined); // expected-error {{use of undeclared identifier 'not_defined'}}
+}
+
+enum MyEnum {
+ ME_foo
+};
+
+enum ForwE; // expected-error {{ISO C++ forbids forward references to 'enum' types}}
+
+void testEnum(void *p) {
+ enum MyEnum myen;
+ id box = @(myen);
+ box = @(ME_foo);
+ box = @(*(enum ForwE*)p); // expected-error {{incomplete type 'enum ForwE' used in a boxed expression}}
+}
diff --git a/test/SemaObjCXX/crash.mm b/test/SemaObjCXX/crash.mm
new file mode 100644
index 0000000..345f72e
--- /dev/null
+++ b/test/SemaObjCXX/crash.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+// <rdar://problem/11286701>
+namespace std {
+ template<typename T, typename U> class pair;
+}
+
+@interface NSObject
+@end
+
+@interface Test : NSObject
+@end
+
+@implementation Test
+
+struct EvilStruct {
+} // note the missing semicolon
+
+ typedef std::pair<int, int> IntegerPair; // expected-error{{typedef declarator cannot be qualified}} \
+// expected-error{{typedef name must be an identifier}} \
+// expected-error{{expected ';' after top level declarator}}
+
+@end
diff --git a/test/SemaObjCXX/delay-parsing-cfunctions.mm b/test/SemaObjCXX/delay-parsing-cfunctions.mm
new file mode 100644
index 0000000..fa65dbe
--- /dev/null
+++ b/test/SemaObjCXX/delay-parsing-cfunctions.mm
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -x objective-c++ -std=c++11 -fsyntax-only -Werror -verify -Wno-objc-root-class %s
+// rdar://10387088
+
+struct X {
+X();
+void SortWithCollator();
+};
+
+@interface MyClass
+- (void)someMethod;
+@end
+
+@implementation MyClass
+- (void)someMethod {
+ [self privateMethod]; // clang already does not warn here
+}
+
+int bar(MyClass * myObject) {
+ [myObject privateMethod];
+ return gorfbar(myObject);
+}
+- (void)privateMethod { }
+
+int gorfbar(MyClass * myObject) {
+ [myObject privateMethod];
+ [myObject privateMethod1];
+ return getMe + bar(myObject);
+}
+
+- (void)privateMethod1 {
+ getMe = getMe+1;
+}
+
+static int getMe;
+
+static int test() {
+ return 0;
+}
+
+int x{17};
+
+X::X() = default;
+void X::SortWithCollator() {}
+// pr13418
+namespace {
+ int CurrentTabId() {return 0;}
+}
+@end
diff --git a/test/SemaObjCXX/delay-parsing-cplusfuncs.mm b/test/SemaObjCXX/delay-parsing-cplusfuncs.mm
new file mode 100644
index 0000000..b022709
--- /dev/null
+++ b/test/SemaObjCXX/delay-parsing-cplusfuncs.mm
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -Werror -verify -Wno-objc-root-class %s
+// rdar://10387088
+
+@interface MyClass
+- (void)someMethod;
+@end
+
+struct S {
+ int bar(MyClass * myObject);
+
+ int gorfbar(MyClass * myObject);
+
+ S();
+ S(MyClass *O1, MyClass *O2);
+ S(MyClass *O1);
+
+ MyClass * Obj1, *Obj2;
+
+};
+
+@implementation MyClass
+- (void)someMethod {
+ [self privateMethod]; // clang already does not warn here
+}
+
+int S::bar(MyClass * myObject) {
+ [myObject privateMethod];
+ return gorfbar(myObject);
+}
+- (void)privateMethod { }
+
+int S::gorfbar(MyClass * myObject) {
+ [myObject privateMethod];
+ [myObject privateMethod1];
+ return getMe + bar(myObject);
+}
+
+S::S(MyClass *O1, MyClass *O2) : Obj1(O1), Obj2(O2) {
+ [O1 privateMethod];
+ [O2 privateMethod1];
+}
+S::S(MyClass *O1) : Obj1(O1){ Obj2 = 0; }
+
+S::S() {}
+
+- (void)privateMethod1 {
+ getMe = getMe+1;
+}
+
+static int getMe;
+
+@end
diff --git a/test/SemaObjCXX/delay-parsing-func-tryblock.mm b/test/SemaObjCXX/delay-parsing-func-tryblock.mm
new file mode 100644
index 0000000..8cf615e
--- /dev/null
+++ b/test/SemaObjCXX/delay-parsing-func-tryblock.mm
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -x objective-c++ -fcxx-exceptions -fsyntax-only -Werror -verify -Wno-objc-root-class %s
+// rdar://10387088
+
+@interface MyClass
+- (void)someMethod;
+@end
+
+struct BadReturn {
+ BadReturn(MyClass * myObject);
+ int bar(MyClass * myObject);
+ void MemFunc(MyClass * myObject);
+ int i;
+ MyClass *CObj;
+};
+
+@implementation MyClass
+- (void)someMethod {
+ [self privateMethod]; // clang already does not warn here
+}
+
+int BadReturn::bar(MyClass * myObject) {
+ [myObject privateMethod];
+ return 0;
+}
+
+BadReturn::BadReturn(MyClass * myObject) try : CObj(myObject) {
+} catch(...) {
+ try {
+ [myObject privateMethod];
+ [myObject privateMethod1];
+ getMe = bar(myObject);
+ [CObj privateMethod1];
+ } catch(int ei) {
+ i = ei;
+ } catch(...) {
+ {
+ i = 0;
+ }
+ }
+}
+
+void BadReturn::MemFunc(MyClass * myObject) try {
+} catch(...) {
+ try {
+ [myObject privateMethod];
+ [myObject privateMethod1];
+ getMe = bar(myObject);
+ [CObj privateMethod1];
+ } catch(int ei) {
+ i = ei;
+ } catch(...) {
+ {
+ i = 0;
+ }
+ }
+}
+
+- (void)privateMethod { }
+
+- (void)privateMethod1 {
+ getMe = getMe+1;
+}
+
+static int getMe;
+
+@end
diff --git a/test/SemaObjCXX/exceptions-fragile.mm b/test/SemaObjCXX/exceptions-fragile.mm
index 91b7077..54d9f83 100644
--- a/test/SemaObjCXX/exceptions-fragile.mm
+++ b/test/SemaObjCXX/exceptions-fragile.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fobjc-fragile-abi -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fobjc-runtime=macosx-fragile-10.5 -fsyntax-only -verify %s
@interface NSException @end
void opaque();
diff --git a/test/SemaObjCXX/foreach.mm b/test/SemaObjCXX/foreach.mm
new file mode 100644
index 0000000..3c4b908
--- /dev/null
+++ b/test/SemaObjCXX/foreach.mm
@@ -0,0 +1,61 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -std=c++11 %s
+// rdar://9293227
+
+@class NSArray;
+
+void f(NSArray *a) {
+ id keys;
+ for (int i : a); // expected-error{{selector element type 'int' is not a valid object}}
+ for ((id)2 : a); // expected-error {{for range declaration must declare a variable}} \
+ // expected-warning {{expression result unused}}
+ for (2 : a); // expected-error {{for range declaration must declare a variable}} \
+ // expected-warning {{expression result unused}}
+
+ for (id thisKey : keys);
+}
+
+/* // rdar://9072298 */
+@protocol NSObject @end
+
+@interface NSObject <NSObject> {
+ Class isa;
+}
+@end
+
+typedef struct {
+ unsigned long state;
+ id *itemsPtr;
+ unsigned long *mutationsPtr;
+ unsigned long extra[5];
+} NSFastEnumerationState;
+
+@protocol NSFastEnumeration
+
+- (unsigned long)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(unsigned long)len;
+
+@end
+
+int main ()
+{
+ NSObject<NSFastEnumeration>* collection = 0;
+ for (id thing : collection) { }
+
+ id array;
+ for (int (^b)(void) : array) {
+ if (b() == 10000) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/* rdar://problem/11068137 */
+@interface Test2
+@property (assign) id prop;
+@end
+void test2(NSObject<NSFastEnumeration> *collection) {
+ Test2 *obj;
+ for (obj.prop : collection) { // expected-error {{for range declaration must declare a variable}} \
+ // expected-warning {{property access result unused - getters should not be used for side effects}}
+ }
+}
diff --git a/test/SemaObjCXX/fragile-abi-object-assign.m b/test/SemaObjCXX/fragile-abi-object-assign.m
index 5bb3ac6..b3504e9 100644
--- a/test/SemaObjCXX/fragile-abi-object-assign.m
+++ b/test/SemaObjCXX/fragile-abi-object-assign.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-fragile-abi -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class %s
// rdar://10731065
@interface MyView {}
diff --git a/test/SemaObjCXX/instantiate-stmt.mm b/test/SemaObjCXX/instantiate-stmt.mm
index ff72858..7575f7a 100644
--- a/test/SemaObjCXX/instantiate-stmt.mm
+++ b/test/SemaObjCXX/instantiate-stmt.mm
@@ -38,20 +38,20 @@ template<typename T> void eat(T);
template<typename E, typename T>
void fast_enumeration_test(T collection) {
for (E element in collection) { // expected-error{{selector element type 'int' is not a valid object}} \
- // expected-error{{collection expression type 'vector' is not a valid object}}
+ // expected-error{{the type 'vector' is not a pointer to a fast-enumerable object}}
eat(element);
}
E element;
for (element in collection) // expected-error{{selector element type 'int' is not a valid object}} \
- // expected-error{{collection expression type 'vector' is not a valid object}}
+ // expected-error{{the type 'vector' is not a pointer to a fast-enumerable object}}
eat(element);
- for (NSString *str in collection) // expected-error{{collection expression type 'vector' is not a valid object}}
+ for (NSString *str in collection) // expected-error{{the type 'vector' is not a pointer to a fast-enumerable object}}
eat(str);
NSString *str;
- for (str in collection) // expected-error{{collection expression type 'vector' is not a valid object}}
+ for (str in collection) // expected-error{{the type 'vector' is not a pointer to a fast-enumerable object}}
eat(str);
}
diff --git a/test/SemaObjCXX/message.mm b/test/SemaObjCXX/message.mm
index 5ac2f40..7d8520c 100644
--- a/test/SemaObjCXX/message.mm
+++ b/test/SemaObjCXX/message.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class %s
@interface I1
- (int*)method;
@end
diff --git a/test/SemaObjCXX/objc-container-subscripting.mm b/test/SemaObjCXX/objc-container-subscripting.mm
index c835cbe..537e152 100644
--- a/test/SemaObjCXX/objc-container-subscripting.mm
+++ b/test/SemaObjCXX/objc-container-subscripting.mm
@@ -32,8 +32,8 @@ template void test_dictionary_subscripts(NSMutableDictionary*, id, int); // expe
template<typename T, typename U, typename O>
void test_array_subscripts(T base, U index, O obj) {
- base[index] = obj; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or objective-C pointer type}}
- obj = base[index]; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or objective-C pointer type}}
+ base[index] = obj; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or Objective-C pointer type}}
+ obj = base[index]; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or Objective-C pointer type}}
}
template void test_array_subscripts(NSMutableArray *, int, id);
diff --git a/test/SemaObjCXX/property-synthesis-error.mm b/test/SemaObjCXX/property-synthesis-error.mm
index 4b726d8..4f64a3a 100644
--- a/test/SemaObjCXX/property-synthesis-error.mm
+++ b/test/SemaObjCXX/property-synthesis-error.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -fobjc-default-synthesize-properties %s
// rdar: //8550657
@interface NSArray @end
@@ -72,3 +72,14 @@ private:
@synthesize tcppObject = _tcppObject;
@end
+
+struct IncompleteStruct; // expected-note 2 {{forward declaration of 'IncompleteStruct'}}
+struct ConvertToIncomplete { operator IncompleteStruct&(); };
+@interface SynthIncompleteRef
+@property (readonly, nonatomic) IncompleteStruct& x; // expected-note {{property declared here}}
+@property (readonly, nonatomic) IncompleteStruct& y; // expected-note {{property declared here}}
+@end
+
+@implementation SynthIncompleteRef // expected-error {{cannot synthesize property 'x' with incomplete type 'IncompleteStruct'}}
+@synthesize y; // expected-error {{cannot synthesize property 'y' with incomplete type 'IncompleteStruct'}}
+@end
diff --git a/test/SemaObjCXX/protocol-lookup.mm b/test/SemaObjCXX/protocol-lookup.mm
index bd8444c..e8abf6c 100644
--- a/test/SemaObjCXX/protocol-lookup.mm
+++ b/test/SemaObjCXX/protocol-lookup.mm
@@ -52,5 +52,5 @@
void rdar8575095(id a) {
[id<NSObject>(a) retain];
id<NSObject> x(id<NSObject>(0));
- id<NSObject> x2(id<NSObject>(y)); // expected-warning{{parentheses were disambiguated as a function declarator}}
+ id<NSObject> x2(id<NSObject>(y)); // expected-warning{{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}}
}
diff --git a/test/SemaObjCXX/warn-missing-super.mm b/test/SemaObjCXX/warn-missing-super.mm
new file mode 100644
index 0000000..cd2a6cc
--- /dev/null
+++ b/test/SemaObjCXX/warn-missing-super.mm
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// PR13401
+
+__attribute((objc_root_class)) @interface NSObject
+@end
+
+@interface Dummy : NSObject
+@end
+
+template<typename T> struct shared_ptr {
+ constexpr shared_ptr() {}
+};
+
+@implementation Dummy
+- (void)dealloc
+{
+ constexpr shared_ptr<int> dummy;
+} // expected-warning {{method possibly missing a [super dealloc] call}}
+@end
OpenPOWER on IntegriCloud