summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/AST/ExprConstant.cpp5
-rw-r--r--clang/test/SemaObjCXX/sel-address.mm7
2 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 5eaf40eb2ad..2fb8c9c137b 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -4557,12 +4557,13 @@ public:
} // end anonymous namespace
/// Evaluate an expression as an lvalue. This can be legitimately called on
-/// expressions which are not glvalues, in two cases:
+/// expressions which are not glvalues, in three cases:
/// * function designators in C, and
/// * "extern void" objects
+/// * @selector() expressions in Objective-C
static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info) {
assert(E->isGLValue() || E->getType()->isFunctionType() ||
- E->getType()->isVoidType());
+ E->getType()->isVoidType() || isa<ObjCSelectorExpr>(E));
return LValueExprEvaluator(Info, Result).Visit(E);
}
diff --git a/clang/test/SemaObjCXX/sel-address.mm b/clang/test/SemaObjCXX/sel-address.mm
index 931d793fd50..a1209abd4e6 100644
--- a/clang/test/SemaObjCXX/sel-address.mm
+++ b/clang/test/SemaObjCXX/sel-address.mm
@@ -2,7 +2,8 @@
// pr7390
void f(const SEL& v2) {}
-void g() {
+void g(SEL* _Nonnull);
+void h() {
f(@selector(dealloc));
SEL s = @selector(dealloc);
@@ -11,4 +12,8 @@ void g() {
@selector(dealloc) = s; // expected-error {{expression is not assignable}}
SEL* ps2 = &@selector(dealloc);
+
+ // Shouldn't crash.
+ g(&@selector(foo));
}
+
OpenPOWER on IntegriCloud