<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 11, 2014 at 12:49 PM, Anton Korobeynikov <span dir="ltr"><<a href="mailto:anton@korobeynikov.info" target="_blank">anton@korobeynikov.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Just to make stuff clear.<br>
<br>
Currently we're building the following AST:<br>
<br>
```<br>
`-FunctionDecl 0x7fc5b306d600 <line:4:1, line:7:1> line:4:5 main 'int (void)'<br>
  `-CompoundStmt 0x7fc5b306d940 <col:16, line:7:1><br>
    |-ConditionalOperator 0x7fc5b306d8d0 <line:5:3, col:32> '_Complex long double'<br>
    | |-IntegerLiteral 0x7fc5b306d6f8 <col:3> 'int' 0<br>
    | |-CallExpr 0x7fc5b306d7a0 <col:7, col:17> 'long double'<br>
    | | |-ImplicitCastExpr 0x7fc5b306d788 <col:7> 'long double (*)(long double)' <FunctionToPointerDecay><br>
    | | | `-DeclRefExpr 0x7fc5b306d718 <col:7> 'long double (long double)' Function 0x7fc5b3033e50 'sqrtl' 'long double (long double)'<br>
    | | `-ImplicitCastExpr 0x7fc5b306d7d0 <col:13> 'long double' <FloatingCast><br>
    | |   `-FloatingLiteral 0x7fc5b306d740 <col:13> 'float' 2.000000e+00<br>
    | `-CallExpr 0x7fc5b306d870 <col:21, col:32> '_Complex long double'<br>
    |   |-ImplicitCastExpr 0x7fc5b306d858 <col:21> '_Complex long double (*)(_Complex long double)' <FunctionToPointerDecay><br>
    |   | `-DeclRefExpr 0x7fc5b306d7e8 <col:21> '_Complex long double (_Complex long double)' Function 0x7fc5b3033b30 'csqrtl' '_Complex long double (_Complex long double)'<br>
    |   `-ImplicitCastExpr 0x7fc5b306d8b8 <col:28> '_Complex long double' <FloatingRealToComplex><br>
    |     `-ImplicitCastExpr 0x7fc5b306d8a0 <col:28> 'long double' <FloatingCast><br>
    |       `-FloatingLiteral 0x7fc5b306d810 <col:28> 'float' 2.000000e+00<br>
    `-ReturnStmt 0x7fc5b306d920 <line:6:3, col:10><br>
      `-IntegerLiteral 0x7fc5b306d900 <col:10> 'int' 0<br>
```<br>
<br>
The type of operator itself is correct.</blockquote><div><br></div><div>For your testcase, but not in general. Try <span style="font-size:13px;font-family:arial,sans-serif">(0 ? csqrtl(2.0f) : sqrtl(2.0f)) and you'll see we get the type of the ConditionalOperator wrong.</span><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">However, the types of lhs and rhs do not match. Prior to r219557 there was additional ImplicitCastExpr to convert the result of sqrtl to _Complex long double.</blockquote><div><br></div><div>I see; CheckConditionalOperator should be doing this. Use ImpCastExprToType to convert the operands to the result type in the arithmetic case, after picking the correct type (from the result of UsualArithmeticConversions).</div></div></div></div>