[cfe-commits] r171831 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/varargs_unreachable.c

Ted Kremenek kremenek at apple.com
Mon Jan 7 17:50:40 PST 2013


Author: kremenek
Date: Mon Jan  7 19:50:40 2013
New Revision: 171831

URL: http://llvm.org/viewvc/llvm-project?rev=171831&view=rev
Log:
Don't warn about undefined varargs argument behavior in unreachable code.

Fixes <rdar://problem/12322000>.

Added:
    cfe/trunk/test/Sema/varargs_unreachable.c
Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=171831&r1=171830&r2=171831&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jan  7 19:50:40 2013
@@ -9716,11 +9716,11 @@
     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);

Added: cfe/trunk/test/Sema/varargs_unreachable.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/varargs_unreachable.c?rev=171831&view=auto
==============================================================================
--- cfe/trunk/test/Sema/varargs_unreachable.c (added)
+++ cfe/trunk/test/Sema/varargs_unreachable.c Mon Jan  7 19:50:40 2013
@@ -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





More information about the cfe-commits mailing list