OSDN Git Service

PR c++/49092
[pf3gnuchains/gcc-fork.git] / gcc / optc-gen.awk
index 502b23b..2c4df70 100644 (file)
 # opt-gather.awk, combines the flags of duplicate options and generates a
 # C file.
 #
-# This program uses functions from opt-functions.awk
+
+# This program uses functions from opt-functions.awk and code from
+# opt-read.awk.
 #
-# Usage: awk -f opt-functions.awk -f optc-gen.awk \
+# Usage: awk -f opt-functions.awk -f opt-read.awk -f optc-gen.awk \
 #            [-v header_name=header.h] < inputfile > options.c
 
-BEGIN {
-       n_opts = 0
-       n_langs = 0
-       n_target_save = 0
-       n_extra_vars = 0
-       n_extra_target_vars = 0
-       n_extra_c_includes = 0
-       n_extra_h_includes = 0
-       n_enums = 0
-       quote = "\042"
-       comma = ","
-       FS=SUBSEP
-       # Default the name of header created from opth-gen.awk to options.h
-       if (header_name == "") header_name="options.h"
-}
-
-# Collect the text and flags of each option into an array
-       {
-               if ($1 == "Language") {
-                       langs[n_langs] = $2
-                       n_langs++;
-               }
-               else if ($1 == "TargetSave") {
-                       # Make sure the declarations are put in source order
-                       target_save_decl[n_target_save] = $2
-                       n_target_save++
-               }
-               else if ($1 == "Variable") {
-                       extra_vars[n_extra_vars] = $2
-                       n_extra_vars++
-               }
-               else if ($1 == "TargetVariable") {
-                       # Combination of TargetSave and Variable
-                       extra_vars[n_extra_vars] = $2
-                       n_extra_vars++
-
-                       var = $2
-                       sub(" *=.*", "", var)
-                       orig_var = var
-                       name = var
-                       type = var
-                       sub("^.*[ *]", "", name)
-                       sub(" *" name "$", "", type)
-                       target_save_decl[n_target_save] = type " x_" name
-                       n_target_save++
-
-                       extra_target_vars[n_extra_target_vars] = name
-                       n_extra_target_vars++;
-               }
-               else if ($1 == "HeaderInclude") {
-                       extra_h_includes[n_extra_h_includes++] = $2;
-               }
-               else if ($1 == "SourceInclude")  {
-                       extra_c_includes[n_extra_c_includes++] = $2;
-               }
-               else if ($1 == "Enum") {
-                       props = $2
-                       name = opt_args("Name", props)
-                       type = opt_args("Type", props)
-                       unknown_error = opt_args("UnknownError", props)
-                       enum_names[n_enums] = name
-                       enum_type[name] = type
-                       enum_index[name] = n_enums
-                       enum_unknown_error[name] = unknown_error
-                       enum_help[name] = $3
-                       n_enums++
-               }
-               else if ($1 == "EnumValue")  {
-                       props = $2
-                       enum_name = opt_args("Enum", props)
-                       string = opt_args("String", props)
-                       value = opt_args("Value", props)
-                       val_flags = "0"
-                       val_flags = val_flags \
-                         test_flag("Canonical", props, "| CL_ENUM_CANONICAL") \
-                         test_flag("DriverOnly", props, "| CL_ENUM_DRIVER_ONLY")
-                       enum_data[enum_name] = enum_data[enum_name] \
-                         "  { " quote string quote ", " value ", " val_flags \
-                         " },\n"
-               }
-               else {
-                       name = opt_args("Mask", $1)
-                       if (name == "") {
-                               opts[n_opts]  = $1
-                               flags[n_opts] = $2
-                               help[n_opts]  = $3
-                               for (i = 4; i <= NF; i++)
-                                       help[n_opts] = help[n_opts] " " $i
-                               n_opts++;
-                       }
-               }
-       }
-
 # Dump that array of options into a C file.
 END {
 print "/* This file is auto-generated by optc-gen.awk.  */"
@@ -202,14 +111,15 @@ for (i = 0; i < n_extra_vars; i++) {
        init = extra_vars[i]
        if (var ~ "=" ) {
                sub(".*= *", "", init)
-               sub(" *=.*", "", var)
-               sub("^.*[ *]", "", var)
-               sub("\\[.*\\]$", "", var)
        } else {
                init = "0"
        }
-       var_seen[var] = 1
-       print "  " init ", /* " var " */"
+       sub(" *=.*", "", var)
+       name = var
+       sub("^.*[ *]", "", name)
+       sub("\\[.*\\]$", "", name)
+       var_seen[name] = 1
+       print "  " init ", /* " name " */"
 }
 for (i = 0; i < n_opts; i++) {
        if (flag_set_p("Save", flags[i]))
@@ -362,6 +272,11 @@ for (i = 0; i < n_opts; i++) {
                                print "#error Alias with single argument " \
                                        "allowing negative form"
                }
+               if (alias_posarg != "" \
+                   && flag_set_p("NegativeAlias", flags[i])) {
+                       print "#error Alias with multiple arguments " \
+                               "used with NegativeAlias"
+               }
 
                alias_opt = opt_enum(alias_opt)
                if (alias_posarg == "")
@@ -396,15 +311,21 @@ for (i = 0; i < n_opts; i++) {
        printf(" %d,\n", idx)
        condition = opt_args("Condition", flags[i])
        cl_flags = switch_flags(flags[i])
+       cl_bit_fields = switch_bit_fields(flags[i])
+       cl_zero_bit_fields = switch_bit_fields("")
        if (condition != "")
                printf("#if %s\n" \
                       "    %s,\n" \
+                      "    0, %s,\n" \
                       "#else\n" \
-                      "    CL_DISABLED,\n" \
+                      "    0,\n" \
+                      "    1 /* Disabled.  */, %s,\n" \
                       "#endif\n",
-                      condition, cl_flags, cl_flags)
+                      condition, cl_flags, cl_bit_fields, cl_zero_bit_fields)
        else
-               printf("    %s,\n", cl_flags)
+               printf("    %s,\n" \
+                      "    0, %s,\n",
+                      cl_flags, cl_bit_fields)
        printf("    %s, %s }%s\n", var_ref(opts[i], flags[i]),
               var_set(flags[i]), comma)
 }
@@ -617,6 +538,8 @@ if (have_save) {
                                        var_target_range[name] = "0, 255"
                                else if (otype ~ "^signed +char *$")
                                        var_target_range[name] = "-128, 127"
+                               if (otype == var_type(flags[i]))
+                                       var_target_range[name] = ""
                        }
                        else
                                var_target_other[n_target_other++] = name;