John McCall | 5fb5df9 | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -pedantic -Wno-objc-root-class %s |
| 2 | // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class %s |
Charles Li | 85dec55 | 2015-12-10 01:07:17 +0000 | [diff] [blame] | 3 | // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class -std=c++98 %s |
| 4 | // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class -std=c++11 %s |
Chris Lattner | 8917c5a | 2008-01-25 19:37:24 +0000 | [diff] [blame] | 5 | // rdar://5707001 |
| 6 | |
| 7 | @interface NSNumber; |
| 8 | - () METH; |
Chris Lattner | fd2fe82 | 2008-06-02 21:31:07 +0000 | [diff] [blame] | 9 | - (unsigned) METH2; |
Chris Lattner | 8917c5a | 2008-01-25 19:37:24 +0000 | [diff] [blame] | 10 | @end |
| 11 | |
Chris Lattner | 9a53fdc | 2008-10-26 23:29:41 +0000 | [diff] [blame] | 12 | struct SomeStruct { |
| 13 | int x, y, z, q; |
| 14 | }; |
| 15 | |
Chris Lattner | 77927cc | 2008-01-25 19:43:26 +0000 | [diff] [blame] | 16 | void test1() { |
Chris Lattner | 8917c5a | 2008-01-25 19:37:24 +0000 | [diff] [blame] | 17 | id objects[] = {[NSNumber METH]}; |
Chris Lattner | 77927cc | 2008-01-25 19:43:26 +0000 | [diff] [blame] | 18 | } |
| 19 | |
Richard Trieu | 553b2b2 | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 20 | void test2(NSNumber x) { // expected-error {{interface type 'NSNumber' cannot be passed by value; did you forget * in 'NSNumber'}} |
Steve Naroff | 3260641 | 2009-02-20 22:59:16 +0000 | [diff] [blame] | 21 | id objects[] = {[x METH]}; |
Chris Lattner | bd2d634 | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | void test3(NSNumber *x) { |
Chris Lattner | 77927cc | 2008-01-25 19:43:26 +0000 | [diff] [blame] | 25 | id objects[] = {[x METH]}; |
Chris Lattner | 8917c5a | 2008-01-25 19:37:24 +0000 | [diff] [blame] | 26 | } |
| 27 | |
Chris Lattner | 77927cc | 2008-01-25 19:43:26 +0000 | [diff] [blame] | 28 | |
Chris Lattner | fd2fe82 | 2008-06-02 21:31:07 +0000 | [diff] [blame] | 29 | // rdar://5977581 |
Chris Lattner | bd2d634 | 2008-07-21 06:12:56 +0000 | [diff] [blame] | 30 | void test4() { |
Chris Lattner | fd2fe82 | 2008-06-02 21:31:07 +0000 | [diff] [blame] | 31 | unsigned x[] = {[NSNumber METH2]+2}; |
| 32 | } |
| 33 | |
Chris Lattner | 9a53fdc | 2008-10-26 23:29:41 +0000 | [diff] [blame] | 34 | void test5(NSNumber *x) { |
| 35 | unsigned y[] = { |
| 36 | [4][NSNumber METH2]+2, // expected-warning {{use of GNU 'missing =' extension in designator}} |
| 37 | [4][x METH2]+2 // expected-warning {{use of GNU 'missing =' extension in designator}} |
| 38 | }; |
| 39 | |
| 40 | struct SomeStruct z = { |
Charles Li | 85dec55 | 2015-12-10 01:07:17 +0000 | [diff] [blame] | 41 | .x = [x METH2], // ok in C++98. |
| 42 | #if __cplusplus >= 201103L |
| 43 | // expected-error@-2 {{non-constant-expression cannot be narrowed from type 'unsigned int' to 'int' in initializer list}} |
| 44 | // expected-note@-3 {{insert an explicit cast to silence this issue}} |
| 45 | #endif |
Chris Lattner | 9a53fdc | 2008-10-26 23:29:41 +0000 | [diff] [blame] | 46 | .x [x METH2] // expected-error {{expected '=' or another designator}} |
Charles Li | 85dec55 | 2015-12-10 01:07:17 +0000 | [diff] [blame] | 47 | #if __cplusplus >= 201103L |
| 48 | // expected-error@-2 {{non-constant-expression cannot be narrowed from type 'unsigned int' to 'int' in initializer list}} |
| 49 | // expected-note@-3 {{insert an explicit cast to silence this issue}} |
| 50 | #endif |
Chris Lattner | 9a53fdc | 2008-10-26 23:29:41 +0000 | [diff] [blame] | 51 | }; |
| 52 | } |
Fariborz Jahanian | 9523911 | 2009-11-06 21:48:47 +0000 | [diff] [blame] | 53 | |
| 54 | // rdar://7370882 |
| 55 | @interface SemicolonsAppDelegate |
| 56 | { |
| 57 | id i; |
| 58 | } |
| 59 | @property (assign) id window; |
| 60 | @end |
| 61 | |
| 62 | @implementation SemicolonsAppDelegate |
| 63 | { |
| 64 | id i; |
| 65 | } |
Fariborz Jahanian | 2f48712 | 2009-11-06 22:15:27 +0000 | [diff] [blame] | 66 | @synthesize window=i; |
Fariborz Jahanian | 9523911 | 2009-11-06 21:48:47 +0000 | [diff] [blame] | 67 | @end |
| 68 | |
| 69 | |
| 70 | |