aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorGreg McGary <gkm@gnu.org>1999-10-16 01:25:01 +0000
committerGreg McGary <gkm@gcc.gnu.org>1999-10-16 01:25:01 +0000
commita8aa79754dcc89603567741aac26db144a430700 (patch)
tree2409137ecdec41f774cd2f423cc4ae796502a936 /gcc
parenta9d3cc3f1a1da3d0e5044249891594933e37ab20 (diff)
downloadgcc-a8aa79754dcc89603567741aac26db144a430700.zip
gcc-a8aa79754dcc89603567741aac26db144a430700.tar.gz
gcc-a8aa79754dcc89603567741aac26db144a430700.tar.bz2
flags.h (flag_bounds_check, [...]): New extern decls.
* flags.h (flag_bounds_check, flag_bounded_pointers): New extern decls. * toplev.c (flag_bounds_check, flag_bounded_pointers): New flags. (f_options): Add "bounded-pointers" and "bounds-check" entries. * c-lang.c (lang_init_options): Set flag_bounds_check as "unspecified". (lang_init): Set default for flag_bounds_check if still "unspecified". From-SVN: r30035
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/c-lang.c9
-rw-r--r--gcc/flags.h15
-rw-r--r--gcc/toplev.c21
4 files changed, 51 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5471510..b6e34ec 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+Fri Oct 15 15:17:29 1999 Greg McGary <gkm@gnu.org>
+
+ * flags.h (flag_bounds_check, flag_bounded_pointers): New extern decls.
+ * toplev.c (flag_bounds_check, flag_bounded_pointers): New flags.
+ (f_options): Add "bounded-pointers" and "bounds-check" entries.
+ * c-lang.c (lang_init_options): Set flag_bounds_check as "unspecified".
+ (lang_init): Set default for flag_bounds_check if still "unspecified".
+
Sat Oct 16 13:42:29 1999 Michael Hayes <m.hayes@elec.canterbury.ac.nz>
* config/c4x/c4x.md (HF mode patterns): Add missing modes.
diff --git a/gcc/c-lang.c b/gcc/c-lang.c
index c8efa35..db76187 100644
--- a/gcc/c-lang.c
+++ b/gcc/c-lang.c
@@ -1,5 +1,5 @@
/* Language-specific hook definitions for C front end.
- Copyright (C) 1991, 1995, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1995, 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -28,6 +28,7 @@ Boston, MA 02111-1307, USA. */
#include "c-lex.h"
#include "toplev.h"
#include "output.h"
+#include "flags.h"
#include "ggc.h"
#if USE_CPPLIB
@@ -56,11 +57,17 @@ lang_init_options ()
parse_in.opts = &parse_options;
cpp_options_init (&parse_options);
#endif
+ /* Mark as "unspecified". */
+ flag_bounds_check = -1;
}
void
lang_init ()
{
+ /* If still "unspecified", make it match -fbounded-pointers. */
+ if (flag_bounds_check < 0)
+ flag_bounds_check = flag_bounded_pointers;
+
/* the beginning of the file is a new line; check for # */
/* With luck, we discover the real source file's name from that
and put it in input_filename. */
diff --git a/gcc/flags.h b/gcc/flags.h
index 5291473..e8a66bf 100644
--- a/gcc/flags.h
+++ b/gcc/flags.h
@@ -476,6 +476,21 @@ extern int flag_instrument_function_entry_exit;
/* Perform a peephole pass before sched2. */
extern int flag_peephole2;
+
+/* -fbounded-pointers causes gcc to compile pointers as composite
+ objects occupying three words: the pointer value, the base address
+ of the referent object, and the address immediately beyond the end
+ of the referent object. The base and extent allow us to perform
+ runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
+extern int flag_bounded_pointers;
+
+/* -fcheck-bounds causes gcc to generate array bounds checks.
+ For C, C++: defaults to value of flag_bounded_pointers.
+ For ObjC: defaults to off.
+ For Java: defaults to on.
+ For Fortran: defaults to off.
+ For CHILL: defaults to off. */
+extern int flag_bounds_check;
/* Other basic status info about current function. */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 89a1c90..753d65d 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -752,6 +752,21 @@ int flag_no_ident = 0;
/* This will perform a peephole pass before sched2. */
int flag_peephole2 = 0;
+/* -fbounded-pointers causes gcc to compile pointers as composite
+ objects occupying three words: the pointer value, the base address
+ of the referent object, and the address immediately beyond the end
+ of the referent object. The base and extent allow us to perform
+ runtime bounds checking. -fbounded-pointers implies -fcheck-bounds. */
+int flag_bounded_pointers = 0;
+
+/* -fcheck-bounds causes gcc to generate array bounds checks.
+ For C, C++: defaults to value of flag_bounded_pointers.
+ For ObjC: defaults to off.
+ For Java: defaults to on.
+ For Fortran: defaults to off.
+ For CHILL: defaults to off. */
+int flag_bounds_check = 0;
+
/* Values of the -falign-* flags: how much to align labels in code.
0 means `use default', 1 means `don't align'.
For each variable, there is an _log variant which is the power
@@ -985,7 +1000,11 @@ lang_independent_options f_options[] =
{ "peephole2", &flag_peephole2, 1,
"Enables an rtl peephole pass run before sched2" },
{"math-errno", &flag_errno_math, 1,
- "Set errno after built-in math functions"}
+ "Set errno after built-in math functions"},
+ {"bounded-pointers", &flag_bounded_pointers, 1,
+ "Compile pointers as triples: value, base & end" },
+ {"bounds-check", &flag_bounds_check, 1,
+ "Generate code to check bounds before dereferencing pointers and arrays" }
};
#define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))