Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
6b55276e
Commit
6b55276e
authored
Apr 22, 1999
by
Craig Burley
Committed by
Craig Burley
Apr 22, 1999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support array bounds checking
From-SVN: r26592
parent
01680a25
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
132 additions
and
17 deletions
+132
-17
gcc/f/ChangeLog
+21
-0
gcc/f/com-rt.def
+1
-0
gcc/f/com.c
+0
-0
gcc/f/g77.texi
+76
-14
gcc/f/lang-options.h
+4
-0
gcc/f/news.texi
+16
-1
gcc/f/ste.c
+1
-1
gcc/f/top.c
+9
-0
gcc/f/top.h
+3
-0
gcc/f/version.c
+1
-1
No files found.
gcc/f/ChangeLog
View file @
6b55276e
Fri Apr 23 01:48:28 1999 Craig Burley <craig@jcb-sc.com>
Support new -fsubscript-check and -ff2c-subscript-check options:
* com-rt.def (FFECOM_gfrtRANGE): Describe s_rnge, in libf2c/libF77.
* com.c (ffecom_subscript_check_, ffecom_arrayref_): New functions.
(ffecom_char_args_x_): Use new ffecom_arrayref_ function for
FFEBLD_opARRAYREF case.
Compute character name, array type, and use new
ffecom_subscript_check_ function for FFEBLD_opSUBSTRING case.
(ffecom_expr_): Use new ffecom_arrayref_ function.
(ffecom_ptr_to_expr): Use new ffecom_arrayref_ function.
* g77.texi, news.texi: Document new options.
* top.c, top.h: Support new options.
* news.texi: Fix up some items to not be in "User-Visible Changes".
* ste.c (ffeste_R819B): Fix type for loop variable, to avoid
warnings.
* version.c: Bump version.
Tue Apr 20 01:38:57 1999 Craig Burley <craig@jcb-sc.com>
* bugs.texi, news.texi: Clarify -malign-double situation.
...
...
gcc/f/com-rt.def
View file @
6b55276e
...
...
@@ -66,6 +66,7 @@ DEFGFRT (FFECOM_gfrtCMP, "s_cmp", FFECOM_rttypeINTEGER_, 0, FALSE, FALSE)
DEFGFRT (FFECOM_gfrtCOPY, "s_copy", FFECOM_rttypeVOID_, 0, FALSE, FALSE)
DEFGFRT (FFECOM_gfrtPAUSE, "s_paus", FFECOM_rttypeVOID_, 0, FALSE, FALSE)
DEFGFRT (FFECOM_gfrtSTOP, "s_stop", FFECOM_rttypeVOID_, 0, TRUE, FALSE)
DEFGFRT (FFECOM_gfrtRANGE, "s_rnge", FFECOM_rttypeINTEGER_, 0, TRUE, FALSE)
DEFGFRT (FFECOM_gfrtSRDUE, "s_rdue", FFECOM_rttypeINTEGER_, 0, FALSE, FALSE)
DEFGFRT (FFECOM_gfrtERDUE, "e_rdue", FFECOM_rttypeINTEGER_, 0, FALSE, FALSE)
...
...
gcc/f/com.c
View file @
6b55276e
This diff is collapsed.
Click to expand it.
gcc/f/g77.texi
View file @
6b55276e
...
...
@@ -2,7 +2,7 @@
@c
%**
start
of
header
@setfilename
g77
.
info
@set
last
-
update
1999
-
04
-
17
@set
last
-
update
1999
-
04
-
23
@set
copyrights
-
g77
1995
-
1999
@include
root
.
texi
...
...
@@ -1471,6 +1471,7 @@ by type. Explanations are in the following sections.
-
falias
-
check
-
fargument
-
alias
-
fargument
-
noalias
-
fno
-
argument
-
noalias
-
global
-
fno
-
globals
-
fsubscript
-
check
-
ff2c
-
subscript
-
check
@end
smallexample
@end
table
...
...
@@ -3370,6 +3371,73 @@ and warns about similar disagreements
that are currently believed to not
likely to result in the compiler later crashing
or producing incorrect code.
@cindex -fsubscript-check option
@cindex -ff2c-subscript-check option
@item -fsubscript-check
@itemx -ff2c-subscript-check
@cindex bounds checking
@cindex range checking
@cindex array bounds checking
@cindex subscript checking
@cindex substring checking
@cindex checking subscripts
@cindex checking substrings
Enable generation of run-time checks for array subscripts
and substring start and end points
against the (locally) declared minimum and maximum values.
The current implementation uses the @code{libf2c}
library routine @code{s_rnge} to print the diagnostic.
However, whereas @code{f2c} generates a single check per
reference for a multi-dimensional array, of the computed
offset against the valid offset range (0 through the size of the array),
@code{g77} generates a single check per @emph{subscript} expression.
This catches some cases of potential bugs that @code{f2c} does not,
such as references to below the beginning of an assumed-size array.
@code{g77} also generates checks for @code{CHARACTER} substring references,
something @code{f2c} currently does not do.
Since a future version of @code{g77} might use a different implementation,
use the new @samp{-ff2c-subscript-check} option
if your application requires use of @code{s_rnge} or a compile-time diagnostic.
@emph{Note:} To provide more detailed information on the offending subscript,
@code{g77} provides @code{s_rnge}
with somewhat differently-formatted information.
Here's a sample diagnostic:
@smallexample
Subscript out of range on file line 4, procedure rnge.f/bf.
Attempt to access the -6-th element of variable b[subscript-2-of-2].
Aborted
@end smallexample
The above message indicates that the offending source line is
line 4 of the file @file{rnge.f},
within the program unit (or statement function) named @samp{bf}.
The offended array is named @samp{b}.
The offended array dimension is the second for a two-dimensional array,
and the offending, computed subscript expression was @samp{-6}.
For a @code{CHARACTER} substring reference, the second line has
this appearance:
@smallexample
Attempt to access the 11-th element of variable a[start-substring].
@end smallexample
This indicates that the offended @code{CHARACTER} variable or array
is named @samp{a},
the offended substring position is the starting (leftmost) position,
and the offending substring expression is @samp{11}.
(Though the verbage of @code{s_rnge} is not ideal
for the purpose of the @code{g77} compiler,
the above information should provide adequate diagnostic abilities
to it users.)
@end table
@xref{Code Gen Options,,Options for Code Generation Conventions,
...
...
@@ -11015,6 +11083,8 @@ themselves as @emph{visible} problems some time later.
Overflowing the bounds of an array---usually by writing beyond
the end of it---is one of two kinds of bug that often occurs
in Fortran code.
(Compile your code with the @samp{-fsubscript-check} option
to catch many of these kinds of errors at program run time.)
The other kind of bug is a mismatch between the actual arguments
passed to a procedure and the dummy arguments as declared by that
...
...
@@ -11028,11 +11098,13 @@ That is, these bugs can be quite sensitive to data, including
data representing the placement of other data in memory (that is,
pointers, such as the placement of stack frames in memory).
Plans call for improving @code{g77} so that it can offer
the
@code{g77} now offers
the
ability to catch and report some of these problems at compile, link, or
run time, such as by generating code to detect references to
beyond the bounds of an array, or checking for agreement between
calling and called procedures.
beyond the bounds of most arrays (except assumed-size arrays),
and checking for agreement between calling and called procedures.
Future improvements are likely to be made in the procedure-mismatch area,
at least.
In the meantime, finding and fixing the programming
bugs that lead to these behaviors is, ultimately, the user's
...
...
@@ -11275,7 +11347,6 @@ Better diagnostics:
Run-time facilities:
* Uninitialized Variables at Run Time::
* Bounds Checking at Run Time::
* Portable Unformatted Files::
Debugging:
...
...
@@ -12159,15 +12230,6 @@ some kinds of uninitialized variables at run time.
Note that use of the options @samp{-O -Wuninitialized} can catch
many such bugs at compile time.
@node Bounds Checking at Run Time
@subsection Bounds Checking at Run Time
@code{g77} should offer run-time bounds-checking of array/subscript references
in a fashion similar to @code{f2c}.
Note that @code{g77} already warns about references to out-of-bounds
elements of arrays when it detects these at compile time.
@node Portable Unformatted Files
@subsection Portable Unformatted Files
...
...
gcc/f/lang-options.h
View file @
6b55276e
...
...
@@ -147,6 +147,10 @@ FTNOPT( "-fglobals", "" )
FTNOPT
(
"-fno-globals"
,
"Disable fatal diagnostics about inter-procedural problems"
)
FTNOPT
(
"-ftypeless-boz"
,
"Make prefix-radix non-decimal constants be typeless"
)
FTNOPT
(
"-fno-typeless-boz"
,
""
)
FTNOPT
(
"-fsubscript-check"
,
"Generate code to check array-subscript ranges"
)
FTNOPT
(
"-fno-subscript-check"
,
""
)
FTNOPT
(
"-ff2c-subscript-check"
,
"Generate f2c-like code to check array-subscript ranges"
)
FTNOPT
(
"-fno-f2c-subscript-check"
,
""
)
FTNOPT
(
"-Wglobals"
,
""
)
FTNOPT
(
"-Wno-globals"
,
"Disable warnings about inter-procedural problems"
)
/*"-Wimplicit",*/
...
...
gcc/f/news.texi
View file @
6b55276e
...
...
@@ -9,7 +9,7 @@
@c
in
the
standalone
derivations
of
this
file
(
e
.
g
.
NEWS
).
@set
copyrights
-
news
1995
-
1999
@set
last
-
update
-
news
1999
-
04
-
2
0
@set
last
-
update
-
news
1999
-
04
-
2
3
@include
root
.
texi
...
...
@@ -188,6 +188,17 @@ The @samp{-ax} option is now obeyed when compiling Fortran programs.
@end
ifclear
@item
The
new
@samp
{
-
fsubscript
-
check
}
option
causes
@code
{
g77
}
to
compile
run
-
time
bounds
checks
of
array
subscripts
,
as
well
as
of
substring
start
and
end
points
.
The
current
implementation
uses
the
@code
{
libf2c
}
library
routine
@code
{
s_rnge
}
to
print
the
diagnostic
.
Since
a
future
version
of
@code
{
g77
}
might
use
a
different
implementation
,
use
the
new
@samp
{
-
ff2c
-
subscript
-
check
}
option
if
your
application
requires
use
of
@code
{
s_rnge
}
or
a
compile
-
time
diagnostic
.
@item
Source
file
names
with
the
suffixes
@samp
{.
FOR
}
and
@samp
{.
FPP
}
now
are
recognized
by
@code
{
g77
}
as
if
they
ended
in
@samp
{.
for
}
and
@samp
{.
fpp
},
respectively
.
...
...
@@ -224,12 +235,15 @@ The @samp{-malign-double} option
now
reliably
aligns
@emph
{
all
}
double
-
precision
variables
and
arrays
on
Intel
x86
targets
.
@ifclear
USERVISONLY
@item
Even
without
the
@samp
{
-
malign
-
double
}
option
,
@code
{
g77
}
reliably
aligns
local
double
-
precision
variables
that
are
not
in
@code
{
EQUIVALENCE
}
areas
and
not
@code
{
SAVE
}
'
d
.
@end
ifclear
@ifclear
USERVISONLY
@item
A
substantial
portion
of
the
@code
{
g77
}
front
end
'
s
code
-
generation
component
was
rewritten
.
...
...
@@ -238,6 +252,7 @@ by the @code{gcc} back end.
One
effect
of
this
rewrite
is
that
some
codes
no
longer
produce
a
spurious
``
label
@var
{
lab
}
used
before
containing
binding
contour
''
message
.
@end
ifclear
@item
Support
for
the
@samp
{
-
fugly
}
option
has
been
removed
.
...
...
gcc/f/ste.c
View file @
6b55276e
...
...
@@ -3096,7 +3096,7 @@ ffeste_R819B (ffestw block, ffelab label UNUSED, ffebld expr)
if
(
expr
)
{
tree
loop
;
struct
nesting
*
loop
;
result
=
ffecom_make_tempvar
(
"dowhile"
,
integer_type_node
,
FFETARGET_charactersizeNONE
,
-
1
);
...
...
gcc/f/top.c
View file @
6b55276e
...
...
@@ -82,6 +82,7 @@ bool ffe_is_mainprog_; /* TRUE if current prog unit known to be
bool
ffe_is_null_version_
=
FALSE
;
bool
ffe_is_onetrip_
=
FALSE
;
bool
ffe_is_silent_
=
TRUE
;
bool
ffe_is_subscript_check_
=
FALSE
;
bool
ffe_is_typeless_boz_
=
FALSE
;
bool
ffe_is_pedantic_
=
FFETARGET_defaultIS_PEDANTIC
;
bool
ffe_is_saveall_
;
/* TRUE if mainprog or SAVE (no args) seen. */
...
...
@@ -317,6 +318,14 @@ ffe_decode_option (argc, argv)
ffe_set_is_globals
(
TRUE
);
else
if
(
strcmp
(
&
opt
[
2
],
"no-globals"
)
==
0
)
ffe_set_is_globals
(
FALSE
);
else
if
(
strcmp
(
&
opt
[
2
],
"subscript-check"
)
==
0
)
ffe_set_is_subscript_check
(
TRUE
);
else
if
(
strcmp
(
&
opt
[
2
],
"no-subscript-check"
)
==
0
)
ffe_set_is_subscript_check
(
FALSE
);
else
if
(
strcmp
(
&
opt
[
2
],
"f2c-subscript-check"
)
==
0
)
ffe_set_is_subscript_check
(
TRUE
);
else
if
(
strcmp
(
&
opt
[
2
],
"no-f2c-subscript-check"
)
==
0
)
ffe_set_is_subscript_check
(
FALSE
);
else
if
(
strcmp
(
&
opt
[
2
],
"typeless-boz"
)
==
0
)
ffe_set_is_typeless_boz
(
TRUE
);
else
if
(
strcmp
(
&
opt
[
2
],
"no-typeless-boz"
)
==
0
)
...
...
gcc/f/top.h
View file @
6b55276e
...
...
@@ -97,6 +97,7 @@ extern bool ffe_is_mainprog_;
extern
bool
ffe_is_null_version_
;
extern
bool
ffe_is_onetrip_
;
extern
bool
ffe_is_silent_
;
extern
bool
ffe_is_subscript_check_
;
extern
bool
ffe_is_typeless_boz_
;
extern
bool
ffe_is_pedantic_
;
extern
bool
ffe_is_saveall_
;
...
...
@@ -188,6 +189,7 @@ void ffe_terminate_4 (void);
#define ffe_is_saveall() ffe_is_saveall_
#define ffe_is_second_underscore() ffe_is_second_underscore_
#define ffe_is_silent() ffe_is_silent_
#define ffe_is_subscript_check() ffe_is_subscript_check_
#define ffe_is_typeless_boz() ffe_is_typeless_boz_
#define ffe_is_ugly_args() ffe_is_ugly_args_
#define ffe_is_ugly_assign() ffe_is_ugly_assign_
...
...
@@ -238,6 +240,7 @@ void ffe_terminate_4 (void);
#define ffe_set_is_saveall(f) (ffe_is_saveall_ = (f))
#define ffe_set_is_second_underscore(f) (ffe_is_second_underscore_ = (f))
#define ffe_set_is_silent(f) (ffe_is_silent_ = (f))
#define ffe_set_is_subscript_check(f) (ffe_is_subscript_check_ = (f))
#define ffe_set_is_typeless_boz(f) (ffe_is_typeless_boz_ = (f))
#define ffe_set_is_ugly_args(f) (ffe_is_ugly_args_ = (f))
#define ffe_set_is_ugly_assign(f) (ffe_is_ugly_assign_ = (f))
...
...
gcc/f/version.c
View file @
6b55276e
const
char
*
ffe_version_string
=
"0.5.24-1999042
0
"
;
const
char
*
ffe_version_string
=
"0.5.24-1999042
3
"
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment