brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · f12842b Raw
105 lines · plain
1// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak %s -verify2 3__attribute__((objc_root_class))4@interface NSObject5@end6  7@class Forward;8@class Forward2;9 10// Tests for generic arguments.11 12@interface PC1<T> : NSObject13- (T) get;14- (void) set: (T) v; // expected-note 4 {{parameter}}15@end16 17void test1a(PC1<__weak id> *obj) { // expected-error {{type argument '__weak id' cannot be qualified with '__weak'}}18  id x = [obj get];19  [obj set: x];20}21 22void test1b(PC1<__strong id> *obj) { // expected-error {{type argument '__strong id' cannot be qualified with '__strong'}}23  id x = [obj get];24  [obj set: x];25}26 27void test1c(PC1<id> *obj) {28  id x = [obj get];29  [obj set: x];30}31 32// Test that this doesn't completely kill downstream type-checking.33void test1d(PC1<__weak Forward*> *obj) { // expected-error {{type argument 'Forward *__weak' cannot be qualified with '__weak'}}34  Forward2 *x = [obj get]; // expected-error {{incompatible}}35  [obj set: x]; // expected-error {{incompatible}}36}37 38void test1e(PC1<__strong Forward*> *obj) { // expected-error {{type argument 'Forward *__strong' cannot be qualified with '__strong'}}39  Forward2 *x = [obj get]; // expected-error {{incompatible}}40  [obj set: x]; // expected-error {{incompatible}}41}42 43void test1f(PC1<Forward*> *obj) {44  Forward2 *x = [obj get]; // expected-error {{incompatible}}45  [obj set: x]; // expected-error {{incompatible}}46}47 48// Typedefs are fine, just silently ignore them.49typedef __strong id StrongID;50void test1g(PC1<StrongID> *obj) {51  Forward2 *x = [obj get];52  [obj set: x];53}54 55typedef __strong Forward *StrongForward;56void test1h(PC1<StrongForward> *obj) {57  Forward2 *x = [obj get]; // expected-error {{incompatible}}58  [obj set: x]; // expected-error {{incompatible}}59}60 61// These aren't really ARC-specific, but they're the same basic idea.62void test1i(PC1<const id> *obj) { // expected-error {{type argument 'const id' cannot be qualified with 'const'}}63  id x = [obj get];64  [obj set: x];65}66 67void test1j(PC1<volatile id> *obj) { // expected-error {{type argument 'volatile id' cannot be qualified with 'volatile'}}68  id x = [obj get];69  [obj set: x];70}71 72void test1k(PC1<__attribute__((address_space(256))) id> *obj) { // expected-error {{type argument '__attribute__((address_space(256))) id' cannot be qualified with '__attribute__((address_space(256)))'}}73  id x = [obj get];74  [obj set: x];75}76 77// Tests for generic parameter bounds.78 79@interface PC2<T : __strong id> // expected-error {{type bound '__strong id' for type parameter 'T' cannot be qualified with '__strong'}}80@end81 82@interface PC3<T : __weak id> // expected-error {{type bound '__weak id' for type parameter 'T' cannot be qualified with '__weak'}}83@end84 85@interface PC4<T : __strong Forward*> // expected-error {{type bound 'Forward *__strong' for type parameter 'T' cannot be qualified with '__strong'}}86@end87 88@interface PC5<T : __weak Forward*> // expected-error {{type bound 'Forward *__weak' for type parameter 'T' cannot be qualified with '__weak'}}89@end90 91@interface PC6<T : StrongID> // expected-error {{type bound 'StrongID' (aka '__strong id') for type parameter 'T' cannot be qualified with '__strong'}}92@end93 94@interface PC7<T : StrongForward> // expected-error {{type bound 'StrongForward' (aka 'Forward *__strong') for type parameter 'T' cannot be qualified with '__strong'}}95@end96 97// These aren't really ARC-specific, but they're the same basic idea.98@interface PC8<T : const id> // expected-error {{type bound 'const id' for type parameter 'T' cannot be qualified with 'const'}}99@end100 101@interface PC9<T : volatile id> // expected-error {{type bound 'volatile id' for type parameter 'T' cannot be qualified with 'volatile'}}102@end103 104@interface PC10<T : __attribute__((address_space(256))) id> // expected-error {{type bound '__attribute__((address_space(256))) id' for type parameter 'T' cannot be qualified with '__attribute__((address_space(256)))'}}105@end