]> granicus.if.org Git - clang/commitdiff
Check that the return type is complete when calling a member function.
authorAnders Carlsson <andersca@mac.com>
Sat, 10 Oct 2009 00:06:20 +0000 (00:06 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 10 Oct 2009 00:06:20 +0000 (00:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83694 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaCXX/incomplete-call.cpp

index 9615a3cf57db98d1a75efcfbf809dbed0607f046..30ac59e4ca71ae4638261db802721bd63e113d3f 100644 (file)
@@ -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))
index defc851bb4ab3fbde2d8ef26b5ddcf88f9e6ae57..c61b61a9c649549741d5816c20e8da72354615de 100644 (file)
@@ -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'}}
 }