2024-01-12 23:30:44 +08:00
|
|
|
! Copyright 2023-2024 Free Software Foundation, Inc.
|
gdb/fortran: Align intrinsic/variable precedence
Fortran allows variables and function to be named after language defined
intrinsics as they are not reserved keywords. For example, the abs maths
intrinsic can be hidden by a user declaring a variable called abs.
The behavior before this patch was to favour the intrinsic, which meant
that any variables named, for example "allocated", could not be
inspected by GDB.
This patch inverts this priority to bring GDB's behaviour closer to the
Fortran language, where the user defined symbol can hide the intrinsic.
Special care was need to prevent any C symbols from overriding either
Fortran intrinsics or user defined variables. This was observed to be
the case when GDB has access to symbols for abs from libm. This was
solved by only allowing symbols not marked with language_fortran to be
overridden.
In total this brings the order of precedence to the following (highest
first):
1. User defined Fortran variable or function.
2. Fortran intrinsic.
3. Symbols from languages other than Fortran.
The sizeof intrinsic is now case insensitive. This is closer to the
Fortran language. I believe this change is safe enough as it increases
the acceptance of the grammar, rather than restricts it. I.e. it should
not break any existing scripts which rely on it. Unless of course they
rely on SIZEOF being rejected.
GDB built with GCC 13.
No test suite regressions detected. Compilers: GCC, ACfL, Intel, Intel
LLVM, NVHPC; Platforms: x86_64, aarch64.
Existing tests in gdb.fortran cover the invocation of intrinsics
including: intrinsics.exp, shape.exp, rank.exp, lbound-ubound.exp.
Approved-By: Tom Tromey <tom@tromey.com>
2023-08-07 16:12:53 +08:00
|
|
|
!
|
|
|
|
! This program is free software; you can redistribute it and/or modify
|
|
|
|
! it under the terms of the GNU General Public License as published by
|
|
|
|
! the Free Software Foundation; either version 2 of the License, or
|
|
|
|
! (at your option) any later version.
|
|
|
|
!
|
|
|
|
! This program is distributed in the hope that it will be useful,
|
|
|
|
! but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
! GNU General Public License for more details.
|
|
|
|
!
|
|
|
|
! You should have received a copy of the GNU General Public License
|
|
|
|
! along with this program; if not, write to the Free Software
|
|
|
|
! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
program intrinsic_precedence
|
|
|
|
implicit none
|
|
|
|
integer(kind=4) LOC, ubound, minus
|
|
|
|
LOC = 17
|
|
|
|
ubound = 79
|
|
|
|
minus = -1
|
|
|
|
print *, minus, LOC, ubound
|
|
|
|
call abs(minus) !all-assigned
|
|
|
|
contains
|
|
|
|
subroutine abs(i)
|
|
|
|
integer(kind=4) :: i
|
|
|
|
if(i .lt. 0) then
|
|
|
|
i = -i
|
|
|
|
endif
|
|
|
|
print *, i !user-abs
|
|
|
|
end subroutine abs
|
|
|
|
end program intrinsic_precedence
|