Cannot type cast @selector expressions.

llvm-svn: 72284
This commit is contained in:
Fariborz Jahanian 2009-05-22 21:42:52 +00:00
parent 0721c2c155
commit 88fead8c48
3 changed files with 24 additions and 0 deletions

View File

@ -1423,6 +1423,8 @@ def err_typecheck_expect_scalar_operand : Error<
"operand of type %0 where arithmetic or pointer type is required">;
def err_typecheck_cond_incompatible_operands : Error<
"incompatible operand types (%0 and %1)">;
def err_cast_selector_expr : Error<
"cannot type cast @selector expression">;
def warn_typecheck_cond_incompatible_pointers : Warning<
"pointer type mismatch (%0 and %1)">;
def warn_typecheck_cond_pointer_integer_mismatch : Warning<

View File

@ -2820,6 +2820,8 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr) {
diag::err_cast_pointer_to_non_pointer_int)
<< castType << castExpr->getSourceRange();
}
if (isa<ObjCSelectorExpr>(castExpr))
return Diag(castExpr->getLocStart(), diag::err_cast_selector_expr);
return false;
}

View File

@ -0,0 +1,20 @@
// RUN: clang-cc -fsyntax-only -verify %s
@interface Foo
- (char*) foo;
- (void) bar;
@end
@implementation Foo
- (void) bar
{
}
- (char*) foo
{
char* a,b,c;
a = (char*)@selector(bar); // expected-error {{cannot type cast @selector expression}}
return (char*)@selector(bar); // expected-error {{cannot type cast @selector expression}}
}
@end