type.
Copy the code in ActOnStartOfFunctionDef that checks a function's return
type to ActOnStartOfObjCMethodDef. This fixes an assertion failure in
IRGen caused by an uninstantiated return type.
rdar://problem/
38691818
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329879
91177308-0d34-0410-b5e6-
96231b3b80d8
if (!MDecl)
return;
+ QualType ResultType = MDecl->getReturnType();
+ if (!ResultType->isDependentType() && !ResultType->isVoidType() &&
+ !MDecl->isInvalidDecl() &&
+ RequireCompleteType(MDecl->getLocation(), ResultType,
+ diag::err_func_def_incomplete_result))
+ MDecl->setInvalidDecl();
+
// Allow all of Sema to see that we are entering a method definition.
PushDeclContext(FnBodyScope, MDecl);
PushFunctionScope();
--- /dev/null
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -std=c++11 -o - %s | FileCheck %s
+
+template <class T>
+struct TemplateClass {
+ int a = 0;
+};
+
+struct S0;
+
+@interface C1
+- (TemplateClass<S0>)m1;
+@end
+
+// This code used to assert in CodeGen because the return type TemplateClass<S0>
+// wasn't instantiated.
+
+// CHECK: define internal i32 @"\01-[C1 m1]"(
+
+@implementation C1
+- (TemplateClass<S0>)m1 {
+}
+@end
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
-// expected-no-diagnostics
// PR7386
@class NSObject;
-class A;
-template<class T> class V {};
+class A; // expected-note {{forward declaration of 'A'}}
+template<class T> class V { T x; }; // expected-error {{field has incomplete type 'A'}}
@protocol Protocol
- (V<A*>)protocolMethod;
+- (V<A>)method2;
@end
- (V<A*>)protocolMethod {
V<A*> va; return va;
}
+- (V<A>)method2 { // expected-note {{in instantiation of}}
+}
@end