[cfe-commits] r106242 - in /cfe/trunk: lib/AST/Expr.cpp lib/Sema/SemaExpr.cpp test/CodeGenCXX/sel-address.mm test/CodeGenObjCXX/selactor-expr-lvalue.mm
Fariborz Jahanian
fjahanian at apple.com
Thu Jun 17 14:45:48 PDT 2010
Author: fjahanian
Date: Thu Jun 17 16:45:48 2010
New Revision: 106242
URL: http://llvm.org/viewvc/llvm-project?rev=106242&view=rev
Log:
Do not treat @selector as lvalue (unlike g++).
Patch by Nico Weber (pr7390).
Added:
cfe/trunk/test/CodeGenCXX/sel-address.mm
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGenObjCXX/selactor-expr-lvalue.mm
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=106242&r1=106241&r2=106242&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Jun 17 16:45:48 2010
@@ -1194,7 +1194,6 @@
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).
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=106242&r1=106241&r2=106242&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jun 17 16:45:48 2010
@@ -6060,6 +6060,8 @@
<< 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
Added: cfe/trunk/test/CodeGenCXX/sel-address.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/sel-address.mm?rev=106242&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/sel-address.mm (added)
+++ cfe/trunk/test/CodeGenCXX/sel-address.mm Thu Jun 17 16:45:48 2010
@@ -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);
+}
Modified: cfe/trunk/test/CodeGenObjCXX/selactor-expr-lvalue.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/selactor-expr-lvalue.mm?rev=106242&r1=106241&r2=106242&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/selactor-expr-lvalue.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/selactor-expr-lvalue.mm Thu Jun 17 16:45:48 2010
@@ -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
More information about the cfe-commits
mailing list