diff options
author | Hans Wennborg <hans@hanshq.net> | 2014-09-29 23:06:57 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2014-09-29 23:06:57 +0000 |
commit | c543a65783a4c493c4fa412952165098a7340903 (patch) | |
tree | 5f693ca44a604fabce69b84da328a9ff3cb9e8c5 /lib/Sema/SemaExpr.cpp | |
parent | 9b130df765b2ec64e8ab8483ead3a421eacc4984 (diff) |
Don't trap when passing non-POD arguments to variadic functions in MS-compatibility mode
Clang warns (treated as error by default, but still ignored in system headers)
when passing non-POD arguments to variadic functions, and generates a trap
instruction to crash the program if that code is ever run.
Unfortunately, MSVC happily generates code for such calls without a warning,
and there is code in system headers that use it.
This makes Clang not insert the trap instruction when in -fms-compatibility
mode, while still generating the warning/error message.
Differential Revision: http://reviews.llvm.org/D5492
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218640 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 5edabc03b6..0c7cb2e6df 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -800,6 +800,9 @@ Sema::VarArgKind Sema::isValidVarArgType(const QualType &Ty) { if (Ty->isObjCObjectType()) return VAK_Invalid; + if (getLangOpts().MSVCCompat) + return VAK_MSVCUndefined; + // FIXME: In C++11, these cases are conditionally-supported, meaning we're // permitted to reject them. We should consider doing so. return VAK_Undefined; @@ -829,6 +832,7 @@ void Sema::checkVariadicArgument(const Expr *E, VariadicCallType CT) { break; case VAK_Undefined: + case VAK_MSVCUndefined: DiagRuntimeBehavior( E->getLocStart(), nullptr, PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg) |