]> granicus.if.org Git - clang/commitdiff
Extend -Wnon-pod-varargs to check calls made from member pointers.
authorRichard Trieu <rtrieu@google.com>
Sat, 22 Jun 2013 02:30:38 +0000 (02:30 +0000)
committerRichard Trieu <rtrieu@google.com>
Sat, 22 Jun 2013 02:30:38 +0000 (02:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184629 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
lib/Sema/SemaOverload.cpp
test/SemaCXX/vararg-non-pod.cpp

index a960a3d8084652689cb2aedee109fb7066da3eea..27e8962f71ba535e9cf315eeb008ba136211aa78 100644 (file)
@@ -3798,7 +3798,8 @@ Sema::getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto,
       if (CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
         if (Method->isInstance())
           return VariadicMethod;
-    }
+    } else if (Fn && Fn->getType() == Context.BoundMemberTy)
+      return VariadicMethod;
     return VariadicFunction;
   }
   return VariadicDoesNotApply;
index b9daba95f698eef384b6ee1a45950f6c07c4748b..29644b40b74db87503f805731af24dc667a9ba5a 100644 (file)
@@ -10895,6 +10895,9 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
     if (ConvertArgumentsForCall(call, op, 0, proto, Args, RParenLoc))
       return ExprError();
 
+    if (CheckOtherCall(call, proto))
+      return ExprError();
+
     return MaybeBindToTemporary(call);
   }
 
index 056d23fe3323630c3d15d5eedbcf81022996458b..56dafc41f1321e0c0861653e277534e3849acc31 100644 (file)
@@ -31,7 +31,7 @@ void t2()
   c.g(10, version);
 
   void (C::*ptr)(int, ...) = &C::g;
-  (c.*ptr)(10, c);  // TODO: This should also warn.
+  (c.*ptr)(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic method; call will abort at runtime}}
   (c.*ptr)(10, version);
  
   C::h(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic function; call will abort at runtime}}
@@ -173,7 +173,7 @@ namespace t11 {
     (get_f_ptr())(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic function; call will abort at runtime}}
     (get_f_ptr())(10, version);
 
-    (c.*get_m_ptr())(10, c); // TODO: This should also warn.
+    (c.*get_m_ptr())(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic method; call will abort at runtime}}
     (c.*get_m_ptr())(10, version);
 
     (get_b_ptr())(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic block; call will abort at runtime}}
@@ -182,7 +182,7 @@ namespace t11 {
     (arr_f_ptr[3])(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic function; call will abort at runtime}}
     (arr_f_ptr[3])(10, version);
 
-    (c.*arr_m_ptr[3])(10, c); // TODO: This should also warn.
+    (c.*arr_m_ptr[3])(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic method; call will abort at runtime}}
     (c.*arr_m_ptr[3])(10, version);
 
     (arr_b_ptr[3])(10, c); // expected-warning{{cannot pass object of non-POD type 'C' through variadic block; call will abort at runtime}}