diff options
author | Anders Carlsson <andersca@mac.com> | 2009-10-10 00:06:20 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-10-10 00:06:20 +0000 |
commit | eed3e699b581ad9e17f8147f26b882d20d65a317 (patch) | |
tree | 4202e8c6443c782c9f0445192e91434c1c3947b6 | |
parent | 11582f542e183f7a7dfcba82cc4378f42d1527c2 (diff) |
Check that the return type is complete when calling a member function.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83694 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 5 | ||||
-rw-r--r-- | test/SemaCXX/incomplete-call.cpp | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 9615a3cf57..30ac59e4ca 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/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/test/SemaCXX/incomplete-call.cpp b/test/SemaCXX/incomplete-call.cpp index defc851bb4..c61b61a9c6 100644 --- a/test/SemaCXX/incomplete-call.cpp +++ b/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'}} } |