Message ID | f1212af8-c5a4-ae0e-247e-df273784a991@netcologne.de |
---|---|
State | New |
Headers | show |
> 2017-01-22 Thomas Koenig <tkoenig@netcologne.de> > > * arith.c (arith_power): If simplifying integer power expression > to zero, warn if -Winteger-division is given. > > 2017-01-22 Thomas Koenig <tkoenig@netcologne.de> > > * gfortran.dg/integer_exponentiation_7.f90: New test. The idea seems reasonable, but I am not sure about the wording (“truncated” in particular). “Integer exponentiation truncated to constant 0”? Why not “Negative integer exponent has result value zero”? Other than that, OK to commit. FX
Index: arith.c =================================================================== --- arith.c (Revision 244747) +++ arith.c (Arbeitskopie) @@ -874,6 +874,11 @@ arith_power (gfc_expr *op1, gfc_expr *op2, gfc_exp { /* if op2 < 0, op1**op2 == 0 because abs(op1) > 1. */ mpz_set_si (result->value.integer, 0); + if (warn_integer_division) + gfc_warning_now (OPT_Winteger_division, "Integer " + "exponentiation truncated to constant " + "%qs at %L", "0", &result->where); + } else if (gfc_extract_int (op2, &power)) {