diff options
| author | Steve Naroff <snaroff@apple.com> | 2008-06-03 12:56:35 +0000 | 
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2008-06-03 12:56:35 +0000 | 
| commit | 1ba306cde501f2cf7754faa71bb1926b529a7512 (patch) | |
| tree | 2347251a36a9e42c92c37fedb85edf770cfd5020 /clang/lib | |
| parent | 2dd8fdc78ac020ed308f6ba6efd9c4507a6c6517 (diff) | |
| download | bcm5719-llvm-1ba306cde501f2cf7754faa71bb1926b529a7512.tar.gz bcm5719-llvm-1ba306cde501f2cf7754faa71bb1926b529a7512.zip | |
Allow for a GCC cast extension.
Fixes part of <rdar://problem/5980829> clang on xcode: used type 'NSRange' where arithmetic or pointer type is required.
llvm-svn: 51900
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 13 | 
1 files changed, 10 insertions, 3 deletions
| diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 626e829044a..c978acac63d 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -845,9 +845,16 @@ ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,    // C99 6.5.4p2: the cast type needs to be void or scalar and the expression    // type needs to be scalar.    if (!castType->isVoidType()) {  // Cast to void allows any expr type. -    if (!castType->isScalarType() && !castType->isVectorType()) -      return Diag(LParenLoc, diag::err_typecheck_cond_expect_scalar,  -                  castType.getAsString(), SourceRange(LParenLoc, RParenLoc)); +    if (!castType->isScalarType() && !castType->isVectorType()) { +      // GCC struct/union extension. +      if (castType == castExpr->getType() && +          castType->isStructureType() || castType->isUnionType()) +        return Diag(LParenLoc, diag::ext_typecheck_cast_nonscalar, +                    SourceRange(LParenLoc, RParenLoc)); +      else +        return Diag(LParenLoc, diag::err_typecheck_cond_expect_scalar,  +                    castType.getAsString(), SourceRange(LParenLoc, RParenLoc)); +    }      if (!castExpr->getType()->isScalarType() &&           !castExpr->getType()->isVectorType())        return Diag(castExpr->getLocStart(),  | 

