re PR fortran/34536 (Make support of 2.0**-3*5 tighter: Print warning by default)

gcc/fortran:
2007-12-23  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/34536 
	* matchexp.c (match_ext_mult_operand): Print warning for unary 
	operators following arithmetic ones by default.
	(match_ext_add_operand): Likewise.

gcc/testsuite:
2007-12-23  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/34536
	* gfortran.dg/integer_exponentiation_2.f90: Fixed testcase.
	* gfortran.dg/real_const_3.f90: Likewise.
	* gfortran.dg/unary_operator.f90: New test.

From-SVN: r131149
This commit is contained in:
Daniel Franke 2007-12-23 12:34:45 -05:00 committed by Daniel Franke
parent 1584031f69
commit 57c65fb59c
6 changed files with 99 additions and 69 deletions

View File

@ -1,3 +1,10 @@
2007-12-23 Daniel Franke <franke.daniel@gmail.com>
PR fortran/34536
* matchexp.c (match_ext_mult_operand): Print warning for unary
operators following arithmetic ones by default.
(match_ext_add_operand): Likewise.
2007-12-22 Daniel Franke <franke.daniel@gmail.com>
PR fortran/34559

View File

@ -345,10 +345,15 @@ match_ext_mult_operand (gfc_expr **result)
if (i == 0)
return match_mult_operand (result);
if (gfc_notify_std (GFC_STD_GNU, "Extension: Unary operator following "
"arithmetic operator (use parentheses) at %C")
== FAILURE)
return MATCH_ERROR;
if (gfc_notification_std (GFC_STD_GNU) == ERROR)
{
gfc_error ("Extension: Unary operator following "
"arithmetic operator (use parentheses) at %C");
return MATCH_ERROR;
}
else
gfc_warning ("Extension: Unary operator following "
"arithmetic operator (use parentheses) at %C");
m = match_ext_mult_operand (&e);
if (m != MATCH_YES)
@ -449,10 +454,15 @@ match_ext_add_operand (gfc_expr **result)
if (i == 0)
return match_add_operand (result);
if (gfc_notify_std (GFC_STD_GNU, "Extension: Unary operator following "
"arithmetic operator (use parentheses) at %C")
== FAILURE)
return MATCH_ERROR;
if (gfc_notification_std (GFC_STD_GNU) == ERROR)
{
gfc_error ("Extension: Unary operator following "
"arithmetic operator (use parentheses) at %C");
return MATCH_ERROR;
}
else
gfc_warning ("Extension: Unary operator following "
"arithmetic operator (use parentheses) at %C");
m = match_ext_add_operand (&e);
if (m != MATCH_YES)

View File

@ -1,3 +1,10 @@
2007-12-23 Daniel Franke <franke.daniel@gmail.com>
PR fortran/34536
* gfortran.dg/integer_exponentiation_2.f90: Fixed testcase.
* gfortran.dg/real_const_3.f90: Likewise.
* gfortran.dg/unary_operator.f90: New test.
2007-12-23 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/pack2.adb: New test.

View File

@ -32,29 +32,29 @@ subroutine run_me(a, i, z)
call check_equal_r (a**1.0, a)
call check_equal_r (a**2.0, a*a)
call check_equal_r (a**3.0, a*(a**2))
call check_equal_r (a**-1.0, 1/a)
call check_equal_r (a**-2.0, (1/a)*(1/a))
call check_equal_r (a**(-1.0), 1/a)
call check_equal_r (a**(-2.0), (1/a)*(1/a))
call check_equal_r (a**0, 1.0)
call check_equal_r (a**1, a)
call check_equal_r (a**2, a*a)
call check_equal_r (a**3, a*(a**2))
call check_equal_r (a**-1, 1/a)
call check_equal_r (a**-2, (1/a)*(1/a))
call check_equal_r (a**(-1), 1/a)
call check_equal_r (a**(-2), (1/a)*(1/a))
call check_equal_r (a**0_8, 1.0)
call check_equal_r (a**1_8, a)
call check_equal_r (a**2_8, a*a)
call check_equal_r (a**3_8, a*(a**2))
call check_equal_r (a**-1_8, 1/a)
call check_equal_r (a**-2_8, (1/a)*(1/a))
call check_equal_r (a**(-1_8), 1/a)
call check_equal_r (a**(-2_8), (1/a)*(1/a))
call check_equal_c (z**0.0, (1.0,0.0))
call check_equal_c (z**1.0, z)
call check_equal_c (z**2.0, z*z)
call check_equal_c (z**3.0, z*(z**2))
call check_equal_c (z**-1.0, 1/z)
call check_equal_c (z**-2.0, (1/z)*(1/z))
call check_equal_c (z**(-1.0), 1/z)
call check_equal_c (z**(-2.0), (1/z)*(1/z))
call check_equal_c (z**(0.0,0.0), (1.0,0.0))
call check_equal_c (z**(1.0,0.0), z)
@ -67,15 +67,15 @@ subroutine run_me(a, i, z)
call check_equal_c (z**1, z)
call check_equal_c (z**2, z*z)
call check_equal_c (z**3, z*(z**2))
call check_equal_c (z**-1, 1/z)
call check_equal_c (z**-2, (1/z)*(1/z))
call check_equal_c (z**(-1), 1/z)
call check_equal_c (z**(-2), (1/z)*(1/z))
call check_equal_c (z**0_8, (1.0,0.0))
call check_equal_c (z**1_8, z)
call check_equal_c (z**2_8, z*z)
call check_equal_c (z**3_8, z*(z**2))
call check_equal_c (z**-1_8, 1/z)
call check_equal_c (z**-2_8, (1/z)*(1/z))
call check_equal_c (z**(-1_8), 1/z)
call check_equal_c (z**(-2_8), (1/z)*(1/z))
contains
@ -110,44 +110,44 @@ subroutine foo(a)
call gee_i(i**1_1)
call gee_i(i**2_1)
call gee_i(i**3_1)
call gee_i(i**-1_1)
call gee_i(i**-2_1)
call gee_i(i**-3_1)
call gee_i(i**(-1_1))
call gee_i(i**(-2_1))
call gee_i(i**(-3_1))
call gee_i(i**huge(0_1))
call gee_i(i**-huge(0_1))
call gee_i(i**(-huge(0_1)))
call gee_i(i**(-huge(0_1)-1_1))
call gee_i(i**0_2)
call gee_i(i**1_2)
call gee_i(i**2_2)
call gee_i(i**3_2)
call gee_i(i**-1_2)
call gee_i(i**-2_2)
call gee_i(i**-3_2)
call gee_i(i**(-1_2))
call gee_i(i**(-2_2))
call gee_i(i**(-3_2))
call gee_i(i**huge(0_2))
call gee_i(i**-huge(0_2))
call gee_i(i**(-huge(0_2)))
call gee_i(i**(-huge(0_2)-1_2))
call gee_i(i**0_4)
call gee_i(i**1_4)
call gee_i(i**2_4)
call gee_i(i**3_4)
call gee_i(i**-1_4)
call gee_i(i**-2_4)
call gee_i(i**-3_4)
call gee_i(i**(-1_4))
call gee_i(i**(-2_4))
call gee_i(i**(-3_4))
call gee_i(i**huge(0_4))
call gee_i(i**-huge(0_4))
call gee_i(i**(-huge(0_4)))
call gee_i(i**(-huge(0_4)-1_4))
call gee_i(i**0_8)
call gee_i(i**1_8)
call gee_i(i**2_8)
call gee_i(i**3_8)
call gee_i(i**-1_8)
call gee_i(i**-2_8)
call gee_i(i**-3_8)
call gee_i(i**(-1_8))
call gee_i(i**(-2_8))
call gee_i(i**(-3_8))
call gee_i(i**huge(0_8))
call gee_i(i**-huge(0_8))
call gee_i(i**(-huge(0_8)))
call gee_i(i**(-huge(0_8)-1_8))
! Real
@ -155,44 +155,44 @@ subroutine foo(a)
call gee_r(a**1_1)
call gee_r(a**2_1)
call gee_r(a**3_1)
call gee_r(a**-1_1)
call gee_r(a**-2_1)
call gee_r(a**-3_1)
call gee_r(a**(-1_1))
call gee_r(a**(-2_1))
call gee_r(a**(-3_1))
call gee_r(a**huge(0_1))
call gee_r(a**-huge(0_1))
call gee_r(a**(-huge(0_1)))
call gee_r(a**(-huge(0_1)-1_1))
call gee_r(a**0_2)
call gee_r(a**1_2)
call gee_r(a**2_2)
call gee_r(a**3_2)
call gee_r(a**-1_2)
call gee_r(a**-2_2)
call gee_r(a**-3_2)
call gee_r(a**(-1_2))
call gee_r(a**(-2_2))
call gee_r(a**(-3_2))
call gee_r(a**huge(0_2))
call gee_r(a**-huge(0_2))
call gee_r(a**(-huge(0_2)))
call gee_r(a**(-huge(0_2)-1_2))
call gee_r(a**0_4)
call gee_r(a**1_4)
call gee_r(a**2_4)
call gee_r(a**3_4)
call gee_r(a**-1_4)
call gee_r(a**-2_4)
call gee_r(a**-3_4)
call gee_r(a**(-1_4))
call gee_r(a**(-2_4))
call gee_r(a**(-3_4))
call gee_r(a**huge(0_4))
call gee_r(a**-huge(0_4))
call gee_r(a**(-huge(0_4)))
call gee_r(a**(-huge(0_4)-1_4))
call gee_r(a**0_8)
call gee_r(a**1_8)
call gee_r(a**2_8)
call gee_r(a**3_8)
call gee_r(a**-1_8)
call gee_r(a**-2_8)
call gee_r(a**-3_8)
call gee_r(a**(-1_8))
call gee_r(a**(-2_8))
call gee_r(a**(-3_8))
call gee_r(a**huge(0_8))
call gee_r(a**-huge(0_8))
call gee_r(a**(-huge(0_8)))
call gee_r(a**(-huge(0_8)-1_8))
! Complex
@ -200,44 +200,44 @@ subroutine foo(a)
call gee_z(z**1_1)
call gee_z(z**2_1)
call gee_z(z**3_1)
call gee_z(z**-1_1)
call gee_z(z**-2_1)
call gee_z(z**-3_1)
call gee_z(z**(-1_1))
call gee_z(z**(-2_1))
call gee_z(z**(-3_1))
call gee_z(z**huge(0_1))
call gee_z(z**-huge(0_1))
call gee_z(z**(-huge(0_1)))
call gee_z(z**(-huge(0_1)-1_1))
call gee_z(z**0_2)
call gee_z(z**1_2)
call gee_z(z**2_2)
call gee_z(z**3_2)
call gee_z(z**-1_2)
call gee_z(z**-2_2)
call gee_z(z**-3_2)
call gee_z(z**(-1_2))
call gee_z(z**(-2_2))
call gee_z(z**(-3_2))
call gee_z(z**huge(0_2))
call gee_z(z**-huge(0_2))
call gee_z(z**(-huge(0_2)))
call gee_z(z**(-huge(0_2)-1_2))
call gee_z(z**0_4)
call gee_z(z**1_4)
call gee_z(z**2_4)
call gee_z(z**3_4)
call gee_z(z**-1_4)
call gee_z(z**-2_4)
call gee_z(z**-3_4)
call gee_z(z**(-1_4))
call gee_z(z**(-2_4))
call gee_z(z**(-3_4))
call gee_z(z**huge(0_4))
call gee_z(z**-huge(0_4))
call gee_z(z**(-huge(0_4)))
call gee_z(z**(-huge(0_4)-1_4))
call gee_z(z**0_8)
call gee_z(z**1_8)
call gee_z(z**2_8)
call gee_z(z**3_8)
call gee_z(z**-1_8)
call gee_z(z**-2_8)
call gee_z(z**-3_8)
call gee_z(z**(-1_8))
call gee_z(z**(-2_8))
call gee_z(z**(-3_8))
call gee_z(z**huge(0_8))
call gee_z(z**-huge(0_8))
call gee_z(z**(-huge(0_8)))
call gee_z(z**(-huge(0_8)-1_8))
end subroutine foo

View File

@ -28,7 +28,7 @@ program main
write(str,*) 0.0/0.0
if (trim(adjustl(str)) .ne. 'NaN') call abort
write(str,*) 1.0/-0.
write(str,*) 1.0/(-0.)
if (trim(adjustl(str)) .ne. '-Infinity') call abort
write(str,*) -2.0/0.

View File

@ -0,0 +1,6 @@
! { dg-do compile }
! PR fortran/34536 -- unary operators following arithmetic ones
real :: x
x = 2.0 ** -3 * 5 ! { dg-warning "Unary operator following arithmetic operator" }
end