From: Greg McGary Date: Sat, 16 Oct 1999 01:25:01 +0000 (+0000) Subject: flags.h (flag_bounds_check, [...]): New extern decls. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a8aa79754dcc89603567741aac26db144a430700;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 54715100b6e..b6e34ecf649 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +Fri Oct 15 15:17:29 1999 Greg McGary + + * 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 * config/c4x/c4x.md (HF mode patterns): Add missing modes. diff --git a/gcc/c-lang.c b/gcc/c-lang.c index c8efa35ff6f..db761878984 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 52914730297..e8a66bfd2a0 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 89a1c908b64..753d65d65cf 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]))