aboutsummaryrefslogtreecommitdiff
path: root/test/SemaObjC/objc-boxed-expressions-nsvalue.m
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-09-06 18:36:24 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-09-06 18:36:24 +0000
commit36c5ade2f4674b544039d78db4c466756cf142b0 (patch)
tree3d3ed1e1987dbe6444294b1b4e249814b97b97a5 /test/SemaObjC/objc-boxed-expressions-nsvalue.m
parent51ece4aae5857052d224ce52277924c74685714e (diff)
downloadsrc-36c5ade2f4674b544039d78db4c466756cf142b0.tar.gz
src-36c5ade2f4674b544039d78db4c466756cf142b0.zip
Import clang 3.7.0 release (r246257).vendor/clang/clang-release_370-r246257
Notes
Notes: svn path=/vendor/clang/dist/; revision=287512 svn path=/vendor/clang/clang-release_370-r246257/; revision=287513; tag=vendor/clang/clang-release_370-r246257
Diffstat (limited to 'test/SemaObjC/objc-boxed-expressions-nsvalue.m')
-rw-r--r--test/SemaObjC/objc-boxed-expressions-nsvalue.m101
1 files changed, 101 insertions, 0 deletions
diff --git a/test/SemaObjC/objc-boxed-expressions-nsvalue.m b/test/SemaObjC/objc-boxed-expressions-nsvalue.m
new file mode 100644
index 000000000000..1599f28c7944
--- /dev/null
+++ b/test/SemaObjC/objc-boxed-expressions-nsvalue.m
@@ -0,0 +1,101 @@
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.9 -verify %s
+
+#define BOXABLE __attribute__((objc_boxable))
+
+typedef struct BOXABLE _NSPoint {
+ int dummy;
+} NSPoint;
+
+typedef struct BOXABLE _NSSize {
+ int dummy;
+} NSSize;
+
+typedef struct BOXABLE _NSRect {
+ int dummy;
+} NSRect;
+
+typedef struct BOXABLE _CGPoint {
+ int dummy;
+} CGPoint;
+
+typedef struct BOXABLE _CGSize {
+ int dummy;
+} CGSize;
+
+typedef struct BOXABLE _CGRect {
+ int dummy;
+} CGRect;
+
+typedef struct BOXABLE _NSRange {
+ int dummy;
+} NSRange;
+
+struct _NSEdgeInsets {
+ int dummy;
+};
+
+typedef struct BOXABLE _NSEdgeInsets NSEdgeInsets;
+
+typedef struct _SomeStruct {
+ double d;
+} SomeStruct;
+
+typedef union BOXABLE _BoxableUnion {
+ int dummy;
+} BoxableUnion;
+
+void checkNSValueDiagnostic() {
+ NSRect rect;
+ id value = @(rect); // expected-error{{NSValue must be available to use Objective-C boxed expressions}}
+}
+
+@interface NSValue
++ (NSValue *)valueWithBytes:(const void *)value objCType:(const char *)type;
+@end
+
+int main() {
+ NSPoint ns_point;
+ id ns_point_value = @(ns_point);
+
+ NSSize ns_size;
+ id ns_size_value = @(ns_size);
+
+ NSRect ns_rect;
+ id ns_rect_value = @(ns_rect);
+
+ CGPoint cg_point;
+ id cg_point_value = @(cg_point);
+
+ CGSize cg_size;
+ id cg_size_value = @(cg_size);
+
+ CGRect cg_rect;
+ id cg_rect_value = @(cg_rect);
+
+ NSRange ns_range;
+ id ns_range_value = @(ns_range);
+
+ NSEdgeInsets edge_insets;
+ id edge_insets_object = @(edge_insets);
+
+ BoxableUnion boxable_union;
+ id boxed_union = @(boxable_union);
+
+ SomeStruct s;
+ id err = @(s); // expected-error{{illegal type 'SomeStruct' (aka 'struct _SomeStruct') used in a boxed expression}}
+}
+
+CGRect getRect() {
+ CGRect r;
+ return r;
+}
+
+SomeStruct getSomeStruct() {
+ SomeStruct s;
+ return s;
+}
+
+void rvalue() {
+ id rv_rect = @(getRect());
+ id rv_some_struct = @(getSomeStruct()); // expected-error {{illegal type 'SomeStruct' (aka 'struct _SomeStruct') used in a boxed expression}}
+}