opts.c (print_specific_help): Fix off-by-one compare in assertion check.
authorGary Funck <gary@intrepid.com>
Fri, 2 Sep 2011 21:19:17 +0000 (21:19 +0000)
committerGary Funck <gfunck@gcc.gnu.org>
Fri, 2 Sep 2011 21:19:17 +0000 (21:19 +0000)
2011-09-02  Gary Funck <gary@intrepid.com>

* opts.c (print_specific_help): Fix off-by-one compare in
assertion check.
* opts.h (CL_PARAMS, CL_WARNING, CL_OPTIMIZATION, CL_DRIVER,
CL_TARGET, CL_COMMON, CL_JOINED, CL_SEPARATE, CL_UNDOCUMENTED):
Increase by +5 to allow for more languages.
* optc-gen.awk: Generate #if that ensures that the number of
languages is within the implementation-defined limit.

From-SVN: r178491

gcc/ChangeLog
gcc/optc-gen.awk
gcc/opts.c
gcc/opts.h

index b6aeebb40f6269fef609304b7ed47a5daedf45b1..48bdefac5c647fdb133c8fe28ac781b4be1e393d 100644 (file)
@@ -1,3 +1,13 @@
+2011-09-02  Gary Funck <gary@intrepid.com>
+
+       * opts.c (print_specific_help): Fix off-by-one compare in
+       assertion check.
+       * opts.h (CL_PARAMS, CL_WARNING, CL_OPTIMIZATION, CL_DRIVER,
+       CL_TARGET, CL_COMMON, CL_JOINED, CL_SEPARATE, CL_UNDOCUMENTED):
+       Increase by +5 to allow for more languages.
+       * optc-gen.awk: Generate #if that ensures that the number of
+       languages is within the implementation-defined limit.
+
 2011-09-02  Michael Matz  <matz@suse.de>
 
        PR middle-end/50260
index 71a03fbdcb6ed6aae2df6bd2c71ab6b789b6347a..e28c397f48a9a3614d58a172c34b21d855c7d0f6 100644 (file)
@@ -169,6 +169,9 @@ for (i = 0; i < n_langs; i++) {
 
 print "  0\n};\n"
 print "const unsigned int cl_options_count = N_OPTS;\n"
+print "#if (1U << " n_langs ") > CL_MIN_OPTION_CLASS"
+print "  #error the number of languages exceeds the implementation limit"
+print "#endif"
 print "const unsigned int cl_lang_count = " n_langs ";\n"
 
 print "const struct cl_option cl_options[] =\n{"
index 59e8910f18c828196c5bfcfdc9981ad500ae9517..5d5bcb9602853b6e5f573d34e60f6ae43081161f 100644 (file)
@@ -1125,7 +1125,7 @@ print_specific_help (unsigned int include_flags,
 
   /* Sanity check: Make sure that we do not have more
      languages than we have bits available to enumerate them.  */
-  gcc_assert ((1U << cl_lang_count) < CL_MIN_OPTION_CLASS);
+  gcc_assert ((1U << cl_lang_count) <= CL_MIN_OPTION_CLASS);
 
   /* If we have not done so already, obtain
      the desired maximum width of the output.  */
index 3c0fe3f8cb7ec2f890e2ca551361d26f0eb768a6..621cdea49343bf1eb04fbd82d0dbd7043e683d89 100644 (file)
@@ -127,12 +127,12 @@ extern const unsigned int cl_options_count;
 extern const char *const lang_names[];
 extern const unsigned int cl_lang_count;
 
-#define CL_PARAMS               (1U << 11) /* Fake entry.  Used to display --param info with --help.  */
-#define CL_WARNING             (1U << 12) /* Enables an (optional) warning message.  */
-#define CL_OPTIMIZATION                (1U << 13) /* Enables an (optional) optimization.  */
-#define CL_DRIVER              (1U << 14) /* Driver option.  */
-#define CL_TARGET              (1U << 15) /* Target-specific option.  */
-#define CL_COMMON              (1U << 16) /* Language-independent.  */
+#define CL_PARAMS               (1U << 16) /* Fake entry.  Used to display --param info with --help.  */
+#define CL_WARNING             (1U << 17) /* Enables an (optional) warning message.  */
+#define CL_OPTIMIZATION                (1U << 18) /* Enables an (optional) optimization.  */
+#define CL_DRIVER              (1U << 19) /* Driver option.  */
+#define CL_TARGET              (1U << 20) /* Target-specific option.  */
+#define CL_COMMON              (1U << 21) /* Language-independent.  */
 
 #define CL_MIN_OPTION_CLASS    CL_PARAMS
 #define CL_MAX_OPTION_CLASS    CL_COMMON
@@ -142,9 +142,9 @@ extern const unsigned int cl_lang_count;
    This distinction is important because --help will not list options
    which only have these higher bits set.  */
 
-#define CL_JOINED              (1U << 17) /* If takes joined argument.  */
-#define CL_SEPARATE            (1U << 18) /* If takes a separate argument.  */
-#define CL_UNDOCUMENTED                (1U << 19) /* Do not output with --help.  */
+#define CL_JOINED              (1U << 22) /* If takes joined argument.  */
+#define CL_SEPARATE            (1U << 23) /* If takes a separate argument.  */
+#define CL_UNDOCUMENTED                (1U << 24) /* Do not output with --help.  */
 
 /* Flags for an enumerated option argument.  */
 #define CL_ENUM_CANONICAL      (1 << 0) /* Canonical for this value.  */