зеркало из https://github.com/microsoft/clang.git
Do not treat @selector as lvalue (unlike g++).
Patch by Nico Weber (pr7390). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106242 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
0c05a1bae9
Коммит
949bd4b611
|
@ -1194,7 +1194,6 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const {
|
|||
case ObjCIsaExprClass:
|
||||
case StringLiteralClass: // C99 6.5.1p4
|
||||
case ObjCEncodeExprClass: // @encode behaves like its string in every way.
|
||||
case ObjCSelectorExprClass: // @selector
|
||||
return LV_Valid;
|
||||
case ArraySubscriptExprClass: // C99 6.5.3p4 (e1[e2] == (*((e1)+(e2))))
|
||||
// For vectors, make sure base is an lvalue (i.e. not a function call).
|
||||
|
|
|
@ -6060,6 +6060,8 @@ QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) {
|
|||
<< op->getType() << op->getSourceRange();
|
||||
if (isSFINAEContext())
|
||||
return QualType();
|
||||
} else if (isa<ObjCSelectorExpr>(op)) {
|
||||
return Context.getPointerType(op->getType());
|
||||
} else if (lval != Expr::LV_Valid && lval != Expr::LV_IncompleteVoidType) {
|
||||
// C99 6.5.3.2p1
|
||||
// The operand must be either an l-value or a function designator
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
// RUN: %clang_cc1 %s -verify -emit-llvm -o %t
|
||||
// pr7390
|
||||
|
||||
void f(const SEL& v2) {}
|
||||
void g() {
|
||||
f(@selector(dealloc));
|
||||
|
||||
SEL s = @selector(dealloc);
|
||||
SEL* ps = &s;
|
||||
|
||||
@selector(dealloc) = s; // expected-error {{expression is not assignable}}
|
||||
|
||||
SEL* ps2 = &@selector(dealloc);
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
// PR7390
|
||||
|
||||
@interface NSObject {}
|
||||
- (void)respondsToSelector:(SEL&)s : (SEL*)s1;
|
||||
- (void)respondsToSelector:(const SEL&)s : (SEL*)s1;
|
||||
- (void) setPriority:(int)p;
|
||||
- (void)Meth;
|
||||
@end
|
||||
|
@ -12,5 +12,5 @@
|
|||
[self respondsToSelector:@selector(setPriority:) : &@selector(setPriority:)];
|
||||
}
|
||||
- (void) setPriority:(int)p{}
|
||||
- (void)respondsToSelector:(SEL&)s : (SEL*)s1 {}
|
||||
- (void)respondsToSelector:(const SEL&)s : (SEL*)s1 {}
|
||||
@end
|
||||
|
|
Загрузка…
Ссылка в новой задаче