]> granicus.if.org Git - clang/commitdiff
Objc's compatibility-alias semantics and code
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 8 Jan 2009 01:10:55 +0000 (01:10 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 8 Jan 2009 01:10:55 +0000 (01:10 +0000)
gen issue fix.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61901 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
lib/Sema/SemaDeclObjC.cpp
test/CodeGenObjC/compatibility-alias.m [new file with mode: 0644]

index eaa8b58b41d52fac4d9ddb0c7f6c8e1e7e54d1b3..ff8acde99510d0a02013541fbe6a46be3bda0124 100644 (file)
@@ -1065,7 +1065,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
     break;
   }
   case Decl::ObjCCompatibleAlias: 
-    ErrorUnsupported(D, "Objective-C compatible alias");
+    // compatibility-alias is a directive and has no code gen.
     break;
 
   case Decl::LinkageSpec: {
index c32a806b7d1a5f9f0e00af5a7115784d9ef46bfc..68e7744582ccb0650ca17f56455a42346d846a60 100644 (file)
@@ -159,6 +159,15 @@ Sema::DeclTy *Sema::ActOnCompatiblityAlias(SourceLocation AtLoc,
   }
   // Check for class declaration
   Decl *CDeclU = LookupDecl(ClassName, Decl::IDNS_Ordinary, TUScope);
+  if (const TypedefDecl *TDecl = dyn_cast_or_null<TypedefDecl>(CDeclU)) {
+    QualType T = TDecl->getUnderlyingType();
+    if (T->isObjCInterfaceType()) {
+      if (NamedDecl *IDecl = T->getAsObjCInterfaceType()->getDecl()) {
+        ClassName = IDecl->getIdentifier();
+        CDeclU = LookupDecl(ClassName, Decl::IDNS_Ordinary, TUScope);
+      }
+    }
+  }
   ObjCInterfaceDecl *CDecl = dyn_cast_or_null<ObjCInterfaceDecl>(CDeclU);
   if (CDecl == 0) {
     Diag(ClassLocation, diag::warn_undef_interface) << ClassName;
diff --git a/test/CodeGenObjC/compatibility-alias.m b/test/CodeGenObjC/compatibility-alias.m
new file mode 100644 (file)
index 0000000..0982a90
--- /dev/null
@@ -0,0 +1,8 @@
+// RUN: clang -emit-llvm -o %t %s
+
+@interface Int1 @end
+
+typedef Int1 Int1Typedef;
+@compatibility_alias Int1Alias Int1Typedef;
+
+@implementation Int1Alias @end