aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/tools/clang
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-08-28 19:28:00 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-08-28 19:28:00 +0000
commit07e2539346f891554433cf296a2b450f5f1e0d8f (patch)
tree1861b8458669307a64f327d68ccc0be73af6b341 /contrib/llvm/tools/clang
parent29ed43fcec4fa3d81627af8fc2954434d16bd8a8 (diff)
downloadsrc-07e2539346f891554433cf296a2b450f5f1e0d8f.tar.gz
src-07e2539346f891554433cf296a2b450f5f1e0d8f.zip
Notes
Diffstat (limited to 'contrib/llvm/tools/clang')
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp
index b8e7ede2716c..05e5d80ad7ed 100644
--- a/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp
@@ -3189,8 +3189,17 @@ bool Sema::SemaBuiltinVAStartImpl(CallExpr *TheCall) {
Diag(TheCall->getArg(1)->getLocStart(),
diag::warn_second_arg_of_va_start_not_last_named_param);
else if (IsCRegister || Type->isReferenceType() ||
- Type->isPromotableIntegerType() ||
- Type->isSpecificBuiltinType(BuiltinType::Float)) {
+ Type->isSpecificBuiltinType(BuiltinType::Float) || [=] {
+ // Promotable integers are UB, but enumerations need a bit of
+ // extra checking to see what their promotable type actually is.
+ if (!Type->isPromotableIntegerType())
+ return false;
+ if (!Type->isEnumeralType())
+ return true;
+ const EnumDecl *ED = Type->getAs<EnumType>()->getDecl();
+ return !(ED &&
+ Context.typesAreCompatible(ED->getPromotionType(), Type));
+ }()) {
unsigned Reason = 0;
if (Type->isReferenceType()) Reason = 1;
else if (IsCRegister) Reason = 2;