+2017-06-28 Martin Liska <mliska@suse.cz>
+
+ PR driver/79659
+ * common.opt: Add IntegerRange to various options.
+ * opt-functions.awk (integer_range_info): New function.
+ * optc-gen.awk: Add integer_range_info to cl_options struct.
+ * opts-common.c (decode_cmdline_option): Handle
+ CL_ERR_INT_RANGE_ARG.
+ (cmdline_handle_error): Likewise.
+ * opts.c (print_filtered_help): Show valid interval in
+ when --help is provided.
+ * opts.h (struct cl_option): Add range_min and range_max fields.
+ * config/i386/i386.opt: Add IntegerRange for -mbranch-cost.
+
2017-06-28 Marc Glisse <marc.glisse@inria.fr>
* match.pd ((X & ~Y) | (~X & Y)): Generalize to + and ^.
+2017-06-28 Martin Liska <mliska@suse.cz>
+
+ PR driver/79659
+ * c.opt: Add IntegerRange to various options.
+
2017-06-26 Marek Polacek <polacek@redhat.com>
PR c/80116
Warn about format strings that are not literals.
Wformat-overflow
-C ObjC C++ LTO ObjC++ Warning Alias(Wformat-overflow=, 1, 0)
+C ObjC C++ LTO ObjC++ Warning Alias(Wformat-overflow=, 1, 0) IntegerRange(0, 2)
Warn about function calls with format strings that write past the end
of the destination region. Same as -Wformat-overflow=1.
Warn about zero-length formats.
Wformat=
-C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0)
+C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 2)
Warn about printf/scanf/strftime/strfmon format string anomalies.
Wformat-overflow=
-C ObjC C++ LTO ObjC++ Joined RejectNegative UInteger Var(warn_format_overflow) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 1, 0)
+C ObjC C++ LTO ObjC++ Joined RejectNegative UInteger Var(warn_format_overflow) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 1, 0) IntegerRange(0, 2)
Warn about function calls with format strings that write past the end
of the destination region.
Wformat-truncation=
-C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format_trunc) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 1, 0)
+C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_format_trunc) Warning LangEnabledBy(C ObjC C++ ObjC++,Wformat=, warn_format >= 1, 0) IntegerRange(0, 2)
Warn about calls to snprintf and similar functions that truncate output.
Wignored-qualifiers
and strcpy.
Wstringop-overflow=
-C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_stringop_overflow) Init(2) Warning LangEnabledBy(C ObjC C++ ObjC++, Wall)
+C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_stringop_overflow) Init(2) Warning LangEnabledBy(C ObjC C++ ObjC++, Wall) IntegerRange(0, 4)
Under the control of Object Size type, warn about buffer overflow in string
manipulation functions like memcpy and strcpy.
Warn for placement new expressions with undefined behavior.
Wplacement-new=
-C++ Joined RejectNegative UInteger Var(warn_placement_new) Init(-1) Warning
+C++ Joined RejectNegative UInteger Var(warn_placement_new) Init(-1) Warning IntegerRange(0, 2)
Warn for placement new expressions with undefined behavior.
Wredundant-decls
Warn if left shift of a signed value overflows.
Wshift-overflow=
-C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_shift_overflow) Init(-1) Warning
+C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_shift_overflow) Init(-1) Warning IntegerRange(0, 2)
Warn if left shift of a signed value overflows.
Wshift-count-negative
Warn about unprototyped function declarations.
Wstrict-aliasing=
-C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wall, 3, 0)
+C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wall, 3, 0) IntegerRange(0, 3)
;
Wstrict-overflow=
-C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0)
+C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wall, 1, 0) IntegerRange(0, 5)
;
Wstrict-selector-match
Warn when a const variable is unused.
Wunused-const-variable=
-C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_unused_const_variable) Warning LangEnabledBy(C ObjC,Wunused-variable, 1, 0)
+C ObjC C++ ObjC++ Joined RejectNegative UInteger Var(warn_unused_const_variable) Warning LangEnabledBy(C ObjC,Wunused-variable, 1, 0) IntegerRange(0, 2)
Warn when a const variable is unused.
Wvariadic-macros
Warn if an array is accessed out of bounds.
Warray-bounds=
-Common Joined RejectNegative UInteger Var(warn_array_bounds) Warning
+Common Joined RejectNegative UInteger Var(warn_array_bounds) Warning IntegerRange(0, 2)
Warn if an array is accessed out of bounds.
Wattributes
Common Alias(Wimplicit-fallthrough=,3,0) Warning
Wimplicit-fallthrough=
-Common Var(warn_implicit_fallthrough) RejectNegative Joined UInteger Warning
+Common Var(warn_implicit_fallthrough) RejectNegative Joined UInteger Warning IntegerRange(0, 5)
Warn when a switch case falls through.
Winline
; The initial value of -1 comes from Z_DEFAULT_COMPRESSION in zlib.h.
flto-compression-level=
-Common Joined RejectNegative UInteger Var(flag_lto_compression_level) Init(-1)
+Common Joined RejectNegative UInteger Var(flag_lto_compression_level) Init(-1) IntegerRange(0, 9)
-flto-compression-level=<number> Use zlib compression level <number> for IL.
flto-odr-type-merging
starts and when the destructor finishes.
flifetime-dse=
-Common Joined RejectNegative UInteger Var(flag_lifetime_dse) Optimization
+Common Joined RejectNegative UInteger Var(flag_lifetime_dse) Optimization IntegerRange(0, 2)
flive-range-shrinkage
Common Report Var(flag_live_range_shrinkage) Init(0) Optimization
Enum(asm_dialect) String(att) Value(ASM_ATT)
mbranch-cost=
-Target RejectNegative Joined UInteger Var(ix86_branch_cost)
-Branches are this expensive (1-5, arbitrary units).
+Target RejectNegative Joined UInteger Var(ix86_branch_cost) IntegerRange(1, 5)
+Branches are this expensive (arbitrary units).
mlarge-data-threshold=
Target RejectNegative Joined UInteger Var(ix86_section_threshold) Init(DEFAULT_LARGE_SECTION_THRESHOLD)
return ""
}
+function integer_range_info(range_option)
+{
+ if (range_option != "") {
+ start = nth_arg(0, range_option);
+ end = nth_arg(1, range_option);
+ return start ", " end
+ }
+ else
+ return "-1, -1"
+}
+
# Handle LangEnabledBy(ENABLED_BY_LANGS, ENABLEDBY_NAME, ENABLEDBY_POSARG,
# ENABLEDBY_NEGARG). This function does not return anything.
function lang_enabled_by(enabledby_langs, enabledby_name, enabledby_posarg, enabledby_negarg)
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)
+ printf(" %s, %s, %s }%s\n", var_ref(opts[i], flags[i]),
+ var_set(flags[i]), integer_range_info(opt_args("IntegerRange", flags[i])), comma)
}
print "};"
value = integral_argument (arg);
if (value == -1)
errors |= CL_ERR_UINT_ARG;
+
+ /* Reject value out of a range. */
+ if (option->range_max != -1
+ && (value < option->range_min || value > option->range_max))
+ errors |= CL_ERR_INT_RANGE_ARG;
}
/* If the switch takes an enumerated argument, convert it. */
return true;
}
+ if (errors & CL_ERR_INT_RANGE_ARG)
+ {
+ error_at (loc, "argument to %qs is not between %d and %d",
+ option->opt_text, option->range_min, option->range_max);
+ return true;
+ }
+
if (errors & CL_ERR_ENUM_ARG)
{
const struct cl_enum *e = &cl_enums[option->var_enum];
help = new_help;
}
+ if (option->range_max != -1)
+ {
+ char b[128];
+ snprintf (b, sizeof (b), "<%d,%d>", option->range_min,
+ option->range_max);
+ opt = concat (opt, b, NULL);
+ len += strlen (b);
+ }
+
wrap_help (help, opt, len, columns);
displayed = true;
enum cl_var_type var_type;
/* Value or bit-mask with which to set a field. */
HOST_WIDE_INT var_value;
+ /* Range info minimum, or -1. */
+ int range_min;
+ /* Range info maximum, or -1. */
+ int range_max;
};
/* Records that the state of an option consists of SIZE bytes starting
#define CL_ERR_MISSING_ARG (1 << 1) /* Argument required but missing. */
#define CL_ERR_WRONG_LANG (1 << 2) /* Option for wrong language. */
#define CL_ERR_UINT_ARG (1 << 3) /* Bad unsigned integer argument. */
-#define CL_ERR_ENUM_ARG (1 << 4) /* Bad enumerated argument. */
-#define CL_ERR_NEGATIVE (1 << 5) /* Negative form of option
+#define CL_ERR_INT_RANGE_ARG (1 << 4) /* Bad unsigned integer argument. */
+#define CL_ERR_ENUM_ARG (1 << 5) /* Bad enumerated argument. */
+#define CL_ERR_NEGATIVE (1 << 6) /* Negative form of option
not permitted (together
with OPT_SPECIAL_unknown). */
+2017-06-28 Martin Liska <mliska@suse.cz>
+
+ PR driver/79659
+ * g++.dg/opt/pr79659.C: New test.
+
2017-06-28 Christophe Lyon <christophe.lyon@linaro.org>
* gcc.dg/tree-ssa/copy-sign-1.c: Add c99_runtime effective target
--- /dev/null
+// PR target/79659
+// { dg-do compile }
+// { dg-options "-flifetime-dse=123456" }
+
+// { dg-error "is not between 0 and 2" "" { target *-*-* } 0 }