This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, fortran] Warn about integer**(negative integer)


Hi FX,

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.


You're right, the error message was a bit strange.  Here is the
version of the patch I committed with corresponding change in the
test case.

Regards

	Thomas


Index: fortran/arith.c
===================================================================
--- fortran/arith.c     (Revision 244747)
+++ fortran/arith.c     (Arbeitskopie)
@@ -874,6 +874,10 @@ 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, "Negative "
+                                      "exponent of integer has zero "
+                                      "result at %L", &result->where);
                  }
                else if (gfc_extract_int (op2, &power))
                  {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]