"'%0' declared as array of functions of type %1">;
def err_illegal_decl_array_incomplete_type : Error<
"array has incomplete element type %0">;
+def err_illegal_message_expr_incomplete_type : Error<
+ "objective-c message has incomplete result type %0">;
def err_illegal_decl_array_of_references : Error<
"'%0' declared as array of references of type %1">;
def err_array_star_outside_prototype : Error<
#include "clang/AST/ASTContext.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/ExprCXX.h"
+#include "clang/AST/ExprObjC.h"
#include "clang/AST/TypeLoc.h"
#include "clang/Basic/PartialDiagnostic.h"
#include "clang/Basic/TargetInfo.h"
if (FTy->getResultType()->isReferenceType())
return Owned(E);
}
+ else if (ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(E)) {
+ QualType Ty = ME->getType();
+ if (const PointerType *PT = Ty->getAs<PointerType>())
+ Ty = PT->getPointeeType();
+ else if (const BlockPointerType *BPT = Ty->getAs<BlockPointerType>())
+ Ty = BPT->getPointeeType();
+ if (Ty->isReferenceType())
+ return Owned(E);
+ }
+
// That should be enough to guarantee that this type is complete.
// If it has a trivial destructor, we can avoid the extra copy.
else
Result = ObjCMessageExpr::Create(Context, ReturnType, LBracLoc, Receiver,
Sel, Method, Args, NumArgs, RBracLoc);
+ if (Context.getLangOptions().CPlusPlus && !ReturnType->isVoidType()) {
+ if (RequireCompleteType(LBracLoc, ReturnType,
+ diag::err_illegal_message_expr_incomplete_type))
+ return ExprError();
+ }
return MaybeBindToTemporary(Result);
}
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// PR7386
+
+@class NSObject;
+
+class A;
+template<class T> class V {};
+
+@protocol Protocol
+- (V<A*>)protocolMethod;
+@end
+
+
+@interface I<Protocol>
+@end
+
+
+@implementation I
+- (void)randomMethod:(id)info {
+ V<A*> vec([self protocolMethod]);
+}
+
+- (V<A*>)protocolMethod {
+ V<A*> va; return va;
+}
+@end