diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 9615a3cf57db..30ac59e4ca71 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -4818,6 +4818,11 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, Method->getResultType().getNonReferenceType(), RParenLoc)); + // Check for a valid return type. + if (CheckCallReturnType(Method->getResultType(), MemExpr->getMemberLoc(), + TheCall.get(), Method)) + return true; + // Convert the object argument (for a non-static member function call). if (!Method->isStatic() && PerformObjectArgumentInitialization(ObjectArg, Method)) diff --git a/clang/test/SemaCXX/incomplete-call.cpp b/clang/test/SemaCXX/incomplete-call.cpp index defc851bb4ab..c61b61a9c649 100644 --- a/clang/test/SemaCXX/incomplete-call.cpp +++ b/clang/test/SemaCXX/incomplete-call.cpp @@ -1,9 +1,10 @@ // RUN: clang-cc -fsyntax-only -verify %s -struct A; // expected-note 3 {{forward declaration of 'struct A'}} +struct A; // expected-note 4 {{forward declaration of 'struct A'}} A f(); // expected-note {{note: 'f' declared here}} struct B { + A f(); // expected-note {{'f' declared here}} }; void g() { @@ -13,4 +14,7 @@ void g() { Func fp; fp(); // expected-error {{calling function with incomplete return type 'struct A'}} ((Func)0)(); // expected-error {{calling function with incomplete return type 'struct A'}} + + B b; + b.f(); // expected-error {{calling 'f' with incomplete return type 'struct A'}} }