]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-opts.c (c_common_init_options): Check option array is sorted if checking enabled.
authorNeil Booth <neil@daikokuya.co.uk>
Tue, 13 Aug 2002 06:48:18 +0000 (06:48 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Tue, 13 Aug 2002 06:48:18 +0000 (06:48 +0000)
* c-opts.c (c_common_init_options): Check option array is
sorted if checking enabled.

From-SVN: r56241

gcc/ChangeLog
gcc/c-opts.c

index e125b611b10ac97a8cf45eb8bb01f01074a152b1..6284939c4e15443196fa4d74bd58ba7a61239bfd 100644 (file)
@@ -1,3 +1,8 @@
+2002-08-13  Neil Booth  <neil@daikokuya.co.uk>
+
+       * c-opts.c (c_common_init_options): Check option array is
+       sorted if checking enabled.
+
 2002-08-13  Gabriel Dos Reis  <gdr@nerim.net>
 
        * c-pretty-print.c: #include "c-tree.h".
index 189cb1ba9e1fca2242eab6a43e897fe0cd8de402..2be997147756080ebc659e66d0d1efb4dd15393b 100644 (file)
@@ -495,6 +495,14 @@ c_common_init_options (lang)
      runtime.  */
   qsort (cl_options, N_OPTS, sizeof (struct cl_option), opt_comp);
 #endif
+#if ENABLE_CHECKING
+  size_t i;
+
+  for (i = 1; i < N_OPTS; i++)
+    if (strcmp (cl_options[i - 1].opt_text, cl_options[i].opt_text) >= 0)
+      error ("options array incorrectly sorted: %s is before %s",
+            cl_options[i - 1].opt_text, cl_options[i].opt_text);
+#endif
 
   c_language = lang;
   parse_in = cpp_create_reader (lang == clk_c ? CLK_GNUC89 : CLK_GNUCXX);