mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-28 15:58:57 -04:00

Objective-C++ have a more complex grammar than in Objective-C (surprise!), because (1) The receiver of an instance message can be a qualified name such as ::I or identity<I>::type. (2) Expressions in C++ can start with a type. The receiver grammar isn't actually ambiguous; it just takes a bit of work to parse past the type before deciding whether we have a type or expression. We do this in two places within the grammar: once for message sends and once when we're determining whether a []'d clause in an initializer list is a message send or a C99 designated initializer. This implementation of Objective-C++ message sends contains one known extension beyond GCC's implementation, which is to permit a typename-specifier as the receiver type for a class message, e.g., [typename compute_receiver_type<T>::type method]; Note that the same effect can be achieved in GCC by way of a typedef, e.g., typedef typename computed_receiver_type<T>::type Computed; [Computed method]; so this is merely a convenience. Note also that message sends still cannot involve dependent types or values. llvm-svn: 102031
61 lines
1.1 KiB
Objective-C
61 lines
1.1 KiB
Objective-C
// RUN: %clang_cc1 -fsyntax-only -verify %s -pedantic
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -x objective-c++ %s
|
|
// rdar://5707001
|
|
|
|
@interface NSNumber;
|
|
- () METH;
|
|
- (unsigned) METH2;
|
|
@end
|
|
|
|
struct SomeStruct {
|
|
int x, y, z, q;
|
|
};
|
|
|
|
void test1() {
|
|
id objects[] = {[NSNumber METH]};
|
|
}
|
|
|
|
void test2(NSNumber x) { // expected-error {{Objective-C interface type 'NSNumber' cannot be passed by value; did you forget * in 'NSNumber'}}
|
|
id objects[] = {[x METH]};
|
|
}
|
|
|
|
void test3(NSNumber *x) {
|
|
id objects[] = {[x METH]};
|
|
}
|
|
|
|
|
|
// rdar://5977581
|
|
void test4() {
|
|
unsigned x[] = {[NSNumber METH2]+2};
|
|
}
|
|
|
|
void test5(NSNumber *x) {
|
|
unsigned y[] = {
|
|
[4][NSNumber METH2]+2, // expected-warning {{use of GNU 'missing =' extension in designator}}
|
|
[4][x METH2]+2 // expected-warning {{use of GNU 'missing =' extension in designator}}
|
|
};
|
|
|
|
struct SomeStruct z = {
|
|
.x = [x METH2], // ok.
|
|
.x [x METH2] // expected-error {{expected '=' or another designator}}
|
|
};
|
|
}
|
|
|
|
// rdar://7370882
|
|
@interface SemicolonsAppDelegate
|
|
{
|
|
id i;
|
|
}
|
|
@property (assign) id window;
|
|
@end
|
|
|
|
@implementation SemicolonsAppDelegate
|
|
{
|
|
id i;
|
|
}
|
|
@synthesize window=i;
|
|
@end
|
|
|
|
|
|
|