Author: nico Date: Tue Sep 15 18:17:17 2015 New Revision: 247740 URL: http://llvm.org/viewvc/llvm-project?rev=247740&view=rev Log: Don't crash when passing &@selector to a _Nonnull parameter. Fixes PR24774.
The root cause here is that ObjCSelectorExpr is an rvalue, yet it can have its address taken. That's kind of awkward, but fixing this is awkward in other ways, see https://llvm.org/bugs/show_bug.cgi?id=24774#c16 . For now, just fix the crash. Modified: cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/test/SemaObjCXX/sel-address.mm Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=247740&r1=247739&r2=247740&view=diff ============================================================================== --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Sep 15 18:17:17 2015 @@ -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); } Modified: cfe/trunk/test/SemaObjCXX/sel-address.mm URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/sel-address.mm?rev=247740&r1=247739&r2=247740&view=diff ============================================================================== --- cfe/trunk/test/SemaObjCXX/sel-address.mm (original) +++ cfe/trunk/test/SemaObjCXX/sel-address.mm Tue Sep 15 18:17:17 2015 @@ -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)); } + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits