]> granicus.if.org Git - clang/commitdiff
Don't warn about undefined varargs argument behavior in unreachable code.
authorTed Kremenek <kremenek@apple.com>
Tue, 8 Jan 2013 01:50:40 +0000 (01:50 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 8 Jan 2013 01:50:40 +0000 (01:50 +0000)
Fixes <rdar://problem/12322000>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171831 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/Sema/varargs_unreachable.c [new file with mode: 0644]

index bac897748f723537080b60c8f8b8301c283250cf..3702aa037c1d56b08d3672638e4929cad392f600 100644 (file)
@@ -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 (file)
index 0000000..866bd8f
--- /dev/null
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-apple-darwin9
+// expected-no-diagnostics
+
+// From <rdar://problem/12322000>.  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