mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-17 16:31:02 +00:00
[Sema][ObjC] Ensure that the return type of an ObjC method is a complete
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 llvm-svn: 329879
This commit is contained in:
parent
bcadfee2ad
commit
ff6c4f3702
@ -341,6 +341,13 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) {
|
||||
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();
|
||||
|
22
clang/test/CodeGenObjCXX/instantiate-return.mm
Normal file
22
clang/test/CodeGenObjCXX/instantiate-return.mm
Normal file
@ -0,0 +1,22 @@
|
||||
// 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
|
@ -1,14 +1,14 @@
|
||||
// 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
|
||||
|
||||
|
||||
@ -24,4 +24,6 @@ template<class T> class V {};
|
||||
- (V<A*>)protocolMethod {
|
||||
V<A*> va; return va;
|
||||
}
|
||||
- (V<A>)method2 { // expected-note {{in instantiation of}}
|
||||
}
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user