[Sema] Handle objc_super special lookup when checking builtin compatibility
authorRaul Tambre <raul.tambre@cleveron.com>
Fri, 18 Sep 2020 17:07:05 +0000 (20:07 +0300)
committerRaul Tambre <raul.tambre@cleveron.com>
Fri, 18 Sep 2020 17:51:55 +0000 (20:51 +0300)
objc_super is special and needs LookupPredefedObjCSuperType() called before performing builtin type comparisons.
This fixes an error when compiling macOS headers. A test is added.

Differential Revision: https://reviews.llvm.org/D87917

clang/lib/Sema/SemaDecl.cpp
clang/test/SemaObjCXX/builtin-objcsuper.mm [new file with mode: 0644]

index 20fb5a4d27e7c94725b9c296fa4dfc113bf06163..81d377cebb326ffac209f1c40d2d6dab3c79e109 100644 (file)
@@ -9671,6 +9671,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
             NewFD->addAttr(BuiltinAttr::CreateImplicit(Context, BuiltinID));
           } else {
             ASTContext::GetBuiltinTypeError Error;
+            LookupPredefedObjCSuperType(*this, S, NewFD->getIdentifier());
             QualType BuiltinType = Context.GetBuiltinType(BuiltinID, Error);
 
             if (!Error && !BuiltinType.isNull() &&
diff --git a/clang/test/SemaObjCXX/builtin-objcsuper.mm b/clang/test/SemaObjCXX/builtin-objcsuper.mm
new file mode 100644 (file)
index 0000000..a6baf3c
--- /dev/null
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify %s
+// expected-no-diagnostics
+
+// objc_super has special lookup rules for compatibility with macOS headers, so
+// the following should compile.
+struct objc_super {};
+extern "C" id objc_msgSendSuper(struct objc_super *super, SEL op, ...);
+extern "C" void objc_msgSendSuper_stret(struct objc_super *super, SEL op, ...);