]> granicus.if.org Git - clang/commitdiff
Finish up r51900.
authorSteve Naroff <snaroff@apple.com>
Tue, 3 Jun 2008 13:21:30 +0000 (13:21 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 3 Jun 2008 13:21:30 +0000 (13:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51901 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/gcc-cast-ext.m [new file with mode: 0644]

index c978acac63d634d9f154e8f762aeadd177e258d7..c384a9a5a2c92b4f7c00eb8d071ac9918f5a3425 100644 (file)
@@ -848,10 +848,11 @@ ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
     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
+          castType->isStructureType() || castType->isUnionType()) {
+        Diag(LParenLoc, diag::ext_typecheck_cast_nonscalar,
+             SourceRange(LParenLoc, RParenLoc));
+        return new CastExpr(castType, castExpr, LParenLoc);
+      } else
         return Diag(LParenLoc, diag::err_typecheck_cond_expect_scalar, 
                     castType.getAsString(), SourceRange(LParenLoc, RParenLoc));
     }
diff --git a/test/Sema/gcc-cast-ext.m b/test/Sema/gcc-cast-ext.m
new file mode 100644 (file)
index 0000000..5f6aa47
--- /dev/null
@@ -0,0 +1,18 @@
+// RUN: clang %s -verify -fms-extensions
+@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+typedef struct _NSRange { } NSRange;
+
+@class PBXFileReference;
+
+@interface PBXDocBookmark
++ alloc;
+- autorelease;
+@end
+@implementation PBXDocBookmark  // expected-warning {{incomplete implementation}} expected-warning {{method definition for 'autorelease' not found}} expected-warning {{method definition for 'alloc' not found}}
+
++ (id)bookmarkWithFileReference:(PBXFileReference *)fileRef gylphRange:(NSRange)range anchor:(NSString *)htmlAnchor
+{
+    NSRange r = (NSRange)range;
+    return [[[self alloc] initWithFileReference:fileRef gylphRange:(NSRange)range anchor:(NSString *)htmlAnchor] autorelease];  // expected-warning {{method '-initWithFileReference:gylphRange:anchor:' not found (return type defaults to 'id')}}
+}
+@end