Debian Codegraph @

clang/test/Parser/objc-init.m

raw
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-c99-designator -Wno-objc-root-class %s
3 // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-c99-designator -Wno-objc-root-class -std=c++98 %s
4 // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-c99-designator -Wno-objc-root-class -std=c++11 %s
5
6 @interface NSNumber;
7 - () METH;
8 - (unsigned) METH2;
9 @end
10
11 struct SomeStruct {
12 int x, y, z, q;
13 };
14
15 void test1(void) {
16 id objects[] = {[NSNumber METH]};
17 }
18
19 void test2(NSNumber x) { // expected-error {{interface type 'NSNumber' cannot be passed by value; did you forget * in 'NSNumber'}}
20 id objects[] = {[x METH]};
21 }
22
23 void test3(NSNumber *x) {
24 id objects[] = {[x METH]};
25 }
26
27
28 void test4(void) {
29 unsigned x[] = {[NSNumber METH2]+2};
30 }
31
32 void test5(NSNumber *x) {
33 unsigned y[] = {
34 [4][NSNumber METH2]+2, // expected-warning {{use of GNU 'missing =' extension in designator}}
35 [4][x METH2]+2 // expected-warning {{use of GNU 'missing =' extension in designator}}
36 };
37
38 struct SomeStruct z = {
39 .x = [x METH2], // ok in C++98.
40 #if __cplusplus >= 201103L
41 // expected-error@-2 {{non-constant-expression cannot be narrowed from type 'unsigned int' to 'int' in initializer list}}
42 // expected-note@-3 {{insert an explicit cast to silence this issue}}
43 #endif
44 .x [x METH2] // expected-error {{expected '=' or another designator}}
45 #if __cplusplus >= 201103L
46 // expected-error@-2 {{non-constant-expression cannot be narrowed from type 'unsigned int' to 'int' in initializer list}}
47 // expected-note@-3 {{insert an explicit cast to silence this issue}}
48 #endif
49 };
50 }
51
52 @interface SemicolonsAppDelegate
53 {
54 id i;
55 }
56 @property (assign) id window;
57 @end
58
59 @implementation SemicolonsAppDelegate
60 {
61 id i;
62 }
63 @synthesize window=i;
64 @end
65
66
67