From: Eli Friedman Date: Fri, 16 May 2008 20:37:07 +0000 (+0000) Subject: Sema-based fix for PR2334. The issue is that even if the two sides of X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5835ea2118560258ab7ee6c6dbbca30b57c58b10;p=clang Sema-based fix for PR2334. The issue is that even if the two sides of the condidtional have compatible types, they are not necessarily the same type. Therefore, we cast to the composite type. As a hack, for the moment we assume that the composite type is the type of the left-hand expression; this isn't correct, but it's good enough for most purposes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51202 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 64b53d5884..6132dfddba 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -920,9 +920,12 @@ inline QualType Sema::CheckConditionalOperands( // C99 6.5.15 // differently qualified versions of compatible types, the result type is // a pointer to an appropriately qualified version of the *composite* // type. - // FIXME: Need to return the composite type. + // FIXME: Need to calculate the composite type. // FIXME: Need to add qualifiers - return lexT; + QualType compositeType = lexT; + ImpCastExprToType(lex, compositeType); + ImpCastExprToType(rex, compositeType); + return compositeType; } }