hubert.reinterpretcast added inline comments.
================ Comment at: clang/lib/Sema/SemaExpr.cpp:1542 + if (unsupportedTypeConversion(*this, LHSType, RHSType) && + ACK != ACK_Conditional && ACK != ACK_CompAssign) return QualType(); ---------------- GCC does not allow compound assignments either and that is is a context where the "usual arithmetic conversions" apply. Allowing them means this patch is going to need to be inventive with the semantics, because the type in with the calculation is to be performed is supposed to be the same one that would occur for the non-assigning version of the arithmetic operation. Noting as well that "Conditional" is also a case where the "usual arithmetic conversions" apply. GCC seems to be happy with that particular case for some reason, but I don't think it makes sense to allow it for Clang: GCC's implementation has questionable semantics like choosing whatever type is not the same format as the ABI's 128-bit `long double` as the common type (in other words, the common type is IEEE for `-mabi=ibmlongdouble` and IBM for `-mabi=ieeelongdouble`). GCC behaviour: `x` is "`long double`" and the conditional is `__float128`: ``` gcc -fsyntax-only -xc -<<<$'__ibm128 x;\n__float128 y;\nvoid q(int b) {\n x + (b ? x : y);\n}' <stdin>: In function ‘q’: <stdin>:4:5: error: __float128 and long double cannot be used in the same expression ``` GCC behaviour: `y` is "`long double`" and the conditional is `__ibm128`: ``` gcc -fsyntax-only -xc -<<<$'__ibm128 x;\n__float128 y;\nvoid q(int b) {\n y + (b ? x : y);\n}' -mabi=ieeelongdouble cc1: warning: Using IEEE extended precision ‘long double’ [-Wpsabi] <stdin>: In function ‘q’: <stdin>:4:5: error: __ibm128 and long double cannot be used in the same expression ``` If we go with the GCC behaviour, there should be lots of explaining done. If we don't then, making the case an error avoids the inconsistency of making a choice regarding the common type for conditionals but not other applications of the usual arithmetic conversions. ================ Comment at: clang/test/Sema/float128-ld-incompatibility.cpp:39 + q + b ? q : ld; // expected-no-error } ---------------- There's no tests for compound assignment... Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D109751/new/ https://reviews.llvm.org/D109751 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits