[Fortran] Fix -mod(unsigned, unsigned)
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Test passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
fail
|
Patch failed to apply
|
Commit Message
Hello world,
during testing, I noticed that parameters of the form
- mod(u1,u2) were rejected with an unknown type. The fix
is straightforward, but required an adjustment to another
test case.
Regression-tested. OK for trunk?
gcc/fortran/ChangeLog:
* resolve.cc (resolve_operator): Also handle BT_UNSIGNED.
gcc/testsuite/ChangeLog:
* gfortran.dg/unsigned_38.f90: Add -pedantic and adjust error
message.
* gfortran.dg/unsigned_40.f90: New test.
Comments
On Fri, Nov 01, 2024 at 10:00:29AM +0100, Thomas Koenig wrote:
>
> during testing, I noticed that parameters of the form
> - mod(u1,u2) were rejected with an unknown type. The fix
> is straightforward, but required an adjustment to another
> test case.
>
> Regression-tested. OK for trunk?
>
Yes. Thanks for the patch.
@@ -4253,7 +4253,8 @@ resolve_operator (gfc_expr *e)
case INTRINSIC_UMINUS:
if (op1->ts.type == BT_INTEGER
|| op1->ts.type == BT_REAL
- || op1->ts.type == BT_COMPLEX)
+ || op1->ts.type == BT_COMPLEX
+ || op1->ts.type == BT_UNSIGNED)
{
e->ts = op1->ts;
break;
@@ -1,6 +1,6 @@
! { dg-do compile }
-! { dg-options "-funsigned" }
+! { dg-options "-funsigned -pedantic" }
program main
unsigned, parameter :: u = 7u
- print *,mod(-(u+1u),u) ! { dg-error "Operand of unary numeric operator" }
+ print *,mod(-(u+1u),u) ! { dg-error "Negation of unsigned expression" }
end program main
new file mode 100644
@@ -0,0 +1,19 @@
+! { dg-do run }
+! { dg-options "-funsigned" }
+program memain
+ use iso_fortran_env, only : uint8
+ call test1
+ call test2
+contains
+ subroutine test1
+ unsigned(uint8) :: nface, nmax
+ nface = 12u_1
+ nmax = - mod(-nface+1u,nface)
+ if (nmax /= 251u_1) error stop 1
+ end subroutine test1
+ subroutine test2
+ unsigned(uint8), parameter :: nface = 12u_1
+ unsigned(uint8), parameter :: nmax = - mod(-nface+1u,nface)
+ if (nmax /= 251u_1) error stop 11
+ end subroutine test2
+end program memain