1// RUN: %clang_cc1 -verify -DMAC -triple=i686-apple-macosx10.10 -Wno-objc-root-class %s
2// RUN: %clang_cc1 -verify -DMAC -triple=i686-apple-macosx10.4 -Wno-objc-root-class %s
3// RUN: %clang_cc1 -verify -DMAC -triple=i686-apple-darwin14 -Wno-objc-root-class %s
4// RUN: %clang_cc1 -verify -triple=i686-apple-ios8 -Wno-objc-root-class %s
5
6// RUN: %clang_cc1 -verify -DALLOW -DMAC -triple=i686-apple-macosx10.11 -Wno-objc-root-class %s
7// RUN: %clang_cc1 -verify -DALLOW -DMAC -triple=i686-apple-darwin15 -Wno-objc-root-class %s
8// RUN: %clang_cc1 -verify -DALLOW -DIOS -triple=i686-apple-ios9 -Wno-objc-root-class %s
9// RUN: %clang_cc1 -verify -DALLOW -DOTHER -triple=i686-apple-watchos -Wno-objc-root-class %s
10// RUN: %clang_cc1 -verify -DALLOW -DOTHER -triple=i686-apple-tvos -Wno-objc-root-class %s
11
12// RUN: %clang_cc1 -verify -DALLOW -DOTHER -triple=x86_64-apple-macosx10.10 -Wno-objc-root-class %s
13
14// rdar://21662309
15
16typedef __attribute__((__ext_vector_type__(3))) float float3;
17
18typedef float __m128 __attribute__((__vector_size__(16)));
19
20struct Aggregate { __m128 v; };
21struct AggregateFloat { float v; };
22
23#define AVAILABLE_MACOS_10_10 __attribute__((availability(macos, introduced = 10.10)))
24#define AVAILABLE_MACOS_10_11 __attribute__((availability(macos, introduced = 10.11)))
25
26#define AVAILABLE_IOS_8 __attribute__((availability(ios, introduced = 8.0)))
27#define AVAILABLE_IOS_9 __attribute__((availability(ios, introduced = 9.0)))
28
29@interface VectorMethods
30
31-(void)takeVector:(float3)v; // there should be no diagnostic at declaration
32-(void)takeM128:(__m128)v;
33
34@end
35
36@implementation VectorMethods
37
38#ifndef ALLOW
39
40-(void)takeVector:(float3)v {
41#ifdef MAC
42  // expected-error@-2 {{'float3' (vector of 3 'float' values) parameter type is unsupported; support for vector types for this target is introduced in macOS 10.11}}
43#else
44  // expected-error@-4 {{'float3' (vector of 3 'float' values) parameter type is unsupported; support for vector types for this target is introduced in iOS 9}}
45#endif
46}
47
48-(float3)retVector { // expected-error {{'float3' (vector of 3 'float' values) return type is unsupported}}
49}
50
51-(void)takeVector2:(float3)v AVAILABLE_MACOS_10_10 { // expected-error {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
52}
53
54-(void)takeVector3:(float3)v AVAILABLE_MACOS_10_11 { // expected-error {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
55}
56
57-(void)takeVector4:(float3)v AVAILABLE_IOS_8 { // expected-error {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
58}
59
60-(void)takeVector5:(float3)v AVAILABLE_IOS_9 { // expected-error {{'float3' (vector of 3 'float' values) parameter type is unsupported}}
61}
62
63- (__m128)retM128 { // expected-error {{'__m128' (vector of 4 'float' values) return type is unsupported}}
64}
65
66- (void)takeM128:(__m128)v { // expected-error {{'__m128' (vector of 4 'float' values) parameter type is unsupported}}
67}
68
69#else
70
71// expected-no-diagnostics
72
73-(void)takeVector:(float3)v {
74}
75
76-(float3)retVector {
77  return 0;
78}
79
80- (__m128)retM128 {
81  __m128 value;
82  return value;
83}
84
85- (void)takeM128:(__m128)v {
86}
87
88-(void)takeVector2:(float3)v AVAILABLE_MACOS_10_10 {
89}
90
91- (__m128)retM128_2 AVAILABLE_MACOS_10_10 {
92  __m128 value;
93  return value;
94}
95
96-(void)takeVector3:(float3)v AVAILABLE_MACOS_10_11 { // no error
97}
98
99-(void)takeVector4:(float3)v AVAILABLE_IOS_8 {
100}
101
102-(void)takeVector5:(float3)v AVAILABLE_IOS_9 { // no error
103}
104
105#ifdef OTHER
106// expected-no-diagnostics
107#endif
108
109#endif
110
111-(void)doStuff:(int)m { // no error
112}
113
114-(struct Aggregate)takesAndRetVectorInAggregate:(struct Aggregate)f { // no error
115  struct Aggregate result;
116  return result;
117}
118
119-(struct AggregateFloat)takesAndRetFloatInAggregate:(struct AggregateFloat)f { // no error
120  struct AggregateFloat result;
121  return result;
122}
123
124
125@end
126