flags.h (flag_bounds_check, [...]): New extern decls.
authorGreg McGary <gkm@gnu.org>
Sat, 16 Oct 1999 01:25:01 +0000 (01:25 +0000)
committerGreg McGary <gkm@gcc.gnu.org>
Sat, 16 Oct 1999 01:25:01 +0000 (01:25 +0000)
* 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

gcc/ChangeLog
gcc/c-lang.c
gcc/flags.h
gcc/toplev.c

index 54715100b6e344c68f8c0fdbedd0c395343c2c8f..b6e34ecf649dffdb8fc37bd0c3e14f6e60567637 100644 (file)
@@ -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.
index c8efa35ff6f25ecabd62da410cdd30490824a5b9..db7618789847a294ef72e65c13498d125af27aac 100644 (file)
@@ -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.  */
index 52914730297d96c25597a61b0ffcb19b217babc2..e8a66bfd2a0f028d074c75c90125edbe1b325298 100644 (file)
@@ -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;
 \f
 /* Other basic status info about current function.  */
 
index 89a1c908b64b5a7f3d69ade59b8186feb16f7537..753d65d65cf51789699fd31206ea85ffd41554e5 100644 (file)
@@ -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]))