]> granicus.if.org Git - clang/commitdiff
Arguments to unordered comparison builtins may need implicit casts.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 19 Feb 2009 19:28:43 +0000 (19:28 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 19 Feb 2009 19:28:43 +0000 (19:28 +0000)
 - <rdar://problem/6094103> sema fails to promote type arguments to __builtin_isgreater (and friends)

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

lib/Sema/SemaChecking.cpp
test/Sema/rdr6094103-unordered-compare-promote.c [new file with mode: 0644]

index 2f837822f86e476c3cb04ba551b502de6348a6b8..fdd22fa4bfb459d55e98b11995627c35f36be629 100644 (file)
@@ -267,6 +267,12 @@ bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) {
   // Do standard promotions between the two arguments, returning their common
   // type.
   QualType Res = UsualArithmeticConversions(OrigArg0, OrigArg1, false);
+
+  // Make sure any conversions are pushed back into the call; this is
+  // type safe since unordered compare builtins are declared as "_Bool
+  // foo(...)".
+  TheCall->setArg(0, OrigArg0);
+  TheCall->setArg(1, OrigArg1);
   
   // If the common type isn't a real floating type, then the arguments were
   // invalid for this operation.
diff --git a/test/Sema/rdr6094103-unordered-compare-promote.c b/test/Sema/rdr6094103-unordered-compare-promote.c
new file mode 100644 (file)
index 0000000..7de91f2
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: clang -ast-dump %s 2>&1 | grep ImplicitCastExpr | count 2
+
+int foo (double x, long double y) {
+  // There needs to be an implicit cast on x here.
+  return __builtin_isgreater(x, y);
+}