From cbb99efceb3a2c27ba2382df97f3b69c75974f94 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 8 Jan 2013 01:50:40 +0000 Subject: [PATCH] Don't warn about undefined varargs argument behavior in unreachable code. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171831 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExpr.cpp | 10 +++++----- test/Sema/varargs_unreachable.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 test/Sema/varargs_unreachable.c diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index bac897748f..3702aa037c 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -9716,11 +9716,11 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc, if (TInfo->getType()->isSpecificBuiltinType(BuiltinType::Float)) PromoteType = Context.DoubleTy; if (!PromoteType.isNull()) - Diag(TInfo->getTypeLoc().getBeginLoc(), - diag::warn_second_parameter_to_va_arg_never_compatible) - << TInfo->getType() - << PromoteType - << TInfo->getTypeLoc().getSourceRange(); + DiagRuntimeBehavior(TInfo->getTypeLoc().getBeginLoc(), E, + PDiag(diag::warn_second_parameter_to_va_arg_never_compatible) + << TInfo->getType() + << PromoteType + << TInfo->getTypeLoc().getSourceRange()); } QualType T = TInfo->getType().getNonLValueExprType(Context); diff --git a/test/Sema/varargs_unreachable.c b/test/Sema/varargs_unreachable.c new file mode 100644 index 0000000000..866bd8f626 --- /dev/null +++ b/test/Sema/varargs_unreachable.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-apple-darwin9 +// expected-no-diagnostics + +// From . Do not warn about undefined behavior of parameter +// argument types in unreachable code in a macro. +#define VA_ARG_RDAR12322000(Marker, TYPE) ((sizeof (TYPE) < sizeof (UINTN_RDAR12322000)) ? (TYPE)(__builtin_va_arg (Marker, UINTN_RDAR12322000)) : (TYPE)(__builtin_va_arg (Marker, TYPE))) + +// 64-bit system +typedef unsigned long long UINTN_RDAR12322000; + +int test_VA_ARG_RDAR12322000 (__builtin_va_list Marker) +{ + return VA_ARG_RDAR12322000 (Marker, short); // no-warning +} \ No newline at end of file -- 2.40.0