[Issue 15261] New: [dmd-internal] Trivial problem in BinExp.checkOpAssignTypes
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Oct 29 18:13:55 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=15261
Issue ID: 15261
Summary: [dmd-internal] Trivial problem in
BinExp.checkOpAssignTypes
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: minor
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: k.hara.pg at gmail.com
In BinExp.checkOpAssignTypes:
if (op == TOKmulass ||
op == TOKdivass ||
op == TOKmodass ||
TOKaddass || // TOK enum is used as a boolean value!
op == TOKminass ||
op == TOKpowass)
{
if ((type.isintegral() && t2.isfloating()))
{
warning("%s %s %s is performing truncating conversion",
type.toChars(), Token.toChars(op), t2.toChars());
}
}
But this is not a real problem, because:
1. checkOpAssignTypes is called only from BinAssignExp.semantic
2. BinAssignExp.semantic is used by these concrete classes derived from
BinAssignExp:
(Add|Min|Mul|Div|Mod|Pow)AssignExp
(And|Or|Xor)AssignExp
(Shl|Shr|Ushr)AssignExp
3. However, BinAssignExp.e2.type can have floating point type only in:
(Add|Min|Mul|Div|Mod|Pow)AssignExp
Other cases are rejected before the call of checkOpAssignTypes in
BinAssignExp.semantic.
Test case (compile with -o- -w):
void main()
{
int x;
double y;
x += y; // AddAssignExp -> warning, expected
x -= y; // MinAssignExp -> warning, expected
x *= y; // MulAssignExp -> warning, expected
x /= y; // DivAssignExp -> warning, expected
x %= y; // ModAssignExp -> warning, expected
x ^^= y; // PowAssignExp -> warning, expected
x &= y; // AndAssignExp -> error, does not reach to
checkOpAssignTypes call
x |= y; // OrAssignExp -> error, ditto
x ^= y; // XorAssignExp -> error, ditto
x <<= y; // ShlAssignExp -> error, ditto
x >>= y; // ShrAssignExp -> error, ditto
x >>>= y; // UshrAssignExp -> error, ditto
}
--
More information about the Digitalmars-d-bugs
mailing list