[cfe-commits] r65059 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/Sema/rdr6094103-unordered-compare-promote.c
Daniel Dunbar
daniel at zuster.org
Thu Feb 19 11:28:43 PST 2009
Author: ddunbar
Date: Thu Feb 19 13:28:43 2009
New Revision: 65059
URL: http://llvm.org/viewvc/llvm-project?rev=65059&view=rev
Log:
Arguments to unordered comparison builtins may need implicit casts.
- <rdar://problem/6094103> sema fails to promote type arguments to __builtin_isgreater (and friends)
Added:
cfe/trunk/test/Sema/rdr6094103-unordered-compare-promote.c
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=65059&r1=65058&r2=65059&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Feb 19 13:28:43 2009
@@ -267,6 +267,12 @@
// 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.
Added: cfe/trunk/test/Sema/rdr6094103-unordered-compare-promote.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/rdr6094103-unordered-compare-promote.c?rev=65059&view=auto
==============================================================================
--- cfe/trunk/test/Sema/rdr6094103-unordered-compare-promote.c (added)
+++ cfe/trunk/test/Sema/rdr6094103-unordered-compare-promote.c Thu Feb 19 13:28:43 2009
@@ -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);
+}
More information about the cfe-commits
mailing list