[cfe-commits] r72284 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/SemaObjC/selector-error.m
Fariborz Jahanian
fjahanian at apple.com
Fri May 22 14:42:53 PDT 2009
Author: fjahanian
Date: Fri May 22 16:42:52 2009
New Revision: 72284
URL: http://llvm.org/viewvc/llvm-project?rev=72284&view=rev
Log:
Cannot type cast @selector expressions.
Added:
cfe/trunk/test/SemaObjC/selector-error.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=72284&r1=72283&r2=72284&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May 22 16:42:52 2009
@@ -1423,6 +1423,8 @@
"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<
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=72284&r1=72283&r2=72284&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri May 22 16:42:52 2009
@@ -2820,6 +2820,8 @@
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;
}
Added: cfe/trunk/test/SemaObjC/selector-error.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/selector-error.m?rev=72284&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/selector-error.m (added)
+++ cfe/trunk/test/SemaObjC/selector-error.m Fri May 22 16:42:52 2009
@@ -0,0 +1,20 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+ at interface Foo
+- (char*) foo;
+- (void) bar;
+ at end
+
+ at 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}}
+}
+ at end
+
More information about the cfe-commits
mailing list