[cfe-commits] r72284 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/SemaObjC/selector-error.m

Chris Lattner clattner at apple.com
Wed May 27 22:56:24 PDT 2009


On May 22, 2009, at 2:42 PM, Fariborz Jahanian wrote:

> 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.

Why?  Won't this accept a cast of a parenthesized @selector expression?

-Chris

>
>
> 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
> +
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list