diff options
author | Anders Carlsson <andersca@mac.com> | 2009-01-13 05:48:52 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-01-13 05:48:52 +0000 |
commit | 906fed0fb54a338961aba3aa54802b7d68de94c7 (patch) | |
tree | 0ce6bb608a4a5693b22ecd9d3147f0ee7721ade9 /lib/Sema/SemaExpr.cpp | |
parent | 518fda1d121dcba3ad7276f5e9a94f733f6e5ecd (diff) |
Warn when someone tries to pass a variable with a non-POD type to a varargs function/method/block.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62148 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index d3d3d3556c..2721bb8dc6 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1688,6 +1688,17 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, // Promote the arguments (C99 6.5.2.2p7). for (unsigned i = NumArgsInProto; i != NumArgs; i++) { Expr *Arg = Args[i]; + if (!Arg->getType()->isPODType()) { + int CallType = 0; + if (Fn->getType()->isBlockPointerType()) + CallType = 1; // Block + else if (isa<MemberExpr>(Fn)) + CallType = 2; + + Diag(Arg->getLocStart(), + diag::warn_cannot_pass_non_pod_arg_to_vararg) << + Arg->getType() << CallType; + } DefaultArgumentPromotion(Arg); Call->setArg(i, Arg); } |