c.opt: Add -W(no-)overlength-strings.

gcc:
	* c.opt: Add -W(no-)overlength-strings.
	* doc/invoke.texi: Document it.
	* c-opts.c (c_common_handle_option): -pedantic implies
	-Woverlength-strings, if not explicitly disabled already.
	(c_common_post_options): -Woverlength-strings defaults to off, and
	is always off for C++.
	* c-common.c (fix_string_type): Issue warning about strings longer
	than is portable only if warn_overlength_strings.  Rearrange code
	a little for clarity.
	* configure.in: Check for -Wno-overlength-strings as well before
	enabling -pedantic in stage 1.
	* Makefile.in (STRICT2_WARN): Add -Wno-overlength-strings.
	(gcc.o-warn, insn-automata.o-warn, build/gencondmd.o-warn): Delete.

	* genconditions.c (write_header, write_one_condition)
	(write_conditions, write_writer): Consolidate very long strings
	that were broken up to fit in C89 portable limit.  Don't use
	printf when fputs will do.

gcc/testsuite:
	* gcc.dg/Woverlength-strings.c
	* gcc.dg/Woverlength-strings-pedantic-c89.c
	* gcc.dg/Woverlength-strings-pedantic-c89-no.c
	* gcc.dg/Woverlength-strings-pedantic-c99.c
	* gcc.dg/Woverlength-strings-pedantic-c99-no.c: New tests.

==================================================================

From-SVN: r110360
This commit is contained in:
Zack Weinberg 2006-01-29 03:30:47 +00:00
parent 0f7868fed2
commit 89a42ac8a1
15 changed files with 285 additions and 63 deletions

View File

@ -1,3 +1,24 @@
2006-01-28 Zack Weinberg <zackw@panix.com>
* c.opt: Add -W(no-)overlength-strings.
* doc/invoke.texi: Document it.
* c-opts.c (c_common_handle_option): -pedantic implies
-Woverlength-strings, if not explicitly disabled already.
(c_common_post_options): -Woverlength-strings defaults to off, and
is always off for C++.
* c-common.c (fix_string_type): Issue warning about strings longer
than is portable only if warn_overlength_strings. Rearrange code
a little for clarity.
* configure.in: Check for -Wno-overlength-strings as well before
enabling -pedantic in stage 1.
* Makefile.in (STRICT2_WARN): Add -Wno-overlength-strings.
(gcc.o-warn, insn-automata.o-warn, build/gencondmd.o-warn): Delete.
* genconditions.c (write_header, write_one_condition)
(write_conditions, write_writer): Consolidate very long strings
that were broken up to fit in C89 portable limit. Don't use
printf when fputs will do.
2006-01-28 Adam Nemet <anemet@caviumnetworks.com> 2006-01-28 Adam Nemet <anemet@caviumnetworks.com>
* combine.c (simplify_comparison <AND>): Check * combine.c (simplify_comparison <AND>): Check

View File

@ -177,7 +177,8 @@ LOOSE_WARN = -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
STRICT_WARN = @strict1_warn@ STRICT_WARN = @strict1_warn@
WERROR_FLAGS = @WERROR@ WERROR_FLAGS = @WERROR@
STRICT2_WARN = -pedantic -Wno-long-long -Wno-variadic-macros \ STRICT2_WARN = -pedantic -Wno-long-long -Wno-variadic-macros \
-Wold-style-definition -Wmissing-format-attribute $(WERROR_FLAGS) -Wno-overlength-strings -Wold-style-definition -Wmissing-format-attribute \
$(WERROR_FLAGS)
# This is set by --enable-checking. The idea is to catch forgotten # This is set by --enable-checking. The idea is to catch forgotten
# "extern" tags in header files. # "extern" tags in header files.
@ -195,11 +196,8 @@ VALGRIND_DRIVER_DEFINES = @valgrind_path_defines@
build-warn = $(STRICT_WARN) build-warn = $(STRICT_WARN)
GCC_WARN_CFLAGS = $(LOOSE_WARN) $($(@D)-warn) $(NOCOMMON_FLAG) $($@-warn) GCC_WARN_CFLAGS = $(LOOSE_WARN) $($(@D)-warn) $(NOCOMMON_FLAG) $($@-warn)
# These files are to have -Werror bypassed in stage2: # These files are to have specific diagnostics suppressed, or are not to
# These are very hard to completely clean due to target complexities. # be subject to -Werror:
gcc.o-warn = -Wno-error
insn-automata.o-warn = -Wno-error
build/gencondmd.o-warn = -Wno-error
# Bison-1.75 output often yields (harmless) -Wtraditional warnings # Bison-1.75 output often yields (harmless) -Wtraditional warnings
build/gengtype-yacc.o-warn = -Wno-error build/gengtype-yacc.o-warn = -Wno-error
# flex output may yield harmless "no previous prototype" warnings # flex output may yield harmless "no previous prototype" warnings

View File

@ -844,7 +844,6 @@ fix_string_type (tree value)
{ {
const int wchar_bytes = TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT; const int wchar_bytes = TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT;
const int wide_flag = TREE_TYPE (value) == wchar_array_type_node; const int wide_flag = TREE_TYPE (value) == wchar_array_type_node;
const int nchars_max = flag_isoc99 ? 4095 : 509;
int length = TREE_STRING_LENGTH (value); int length = TREE_STRING_LENGTH (value);
int nchars; int nchars;
tree e_type, i_type, a_type; tree e_type, i_type, a_type;
@ -852,11 +851,24 @@ fix_string_type (tree value)
/* Compute the number of elements, for the array type. */ /* Compute the number of elements, for the array type. */
nchars = wide_flag ? length / wchar_bytes : length; nchars = wide_flag ? length / wchar_bytes : length;
if (pedantic && nchars - 1 > nchars_max && !c_dialect_cxx ()) /* C89 2.2.4.1, C99 5.2.4.1 (Translation limits). The analogous
pedwarn ("string length %qd is greater than the length %qd ISO C%d compilers are required to support", limit in C++98 Annex B is very large (65536) and is not normative,
nchars - 1, nchars_max, flag_isoc99 ? 99 : 89); so we do not diagnose it (warn_overlength_strings is forced off
in c_common_post_options). */
if (warn_overlength_strings)
{
const int nchars_max = flag_isoc99 ? 4095 : 509;
const int relevant_std = flag_isoc99 ? 99 : 90;
if (nchars - 1 > nchars_max)
/* Translators: The %d after 'ISO C' will be 90 or 99. Do not
separate the %d from the 'C'. 'ISO' should not be
translated, but it may be moved after 'C%d' in languages
where modifiers follow nouns. */
pedwarn ("string length %qd is greater than the length %qd "
"ISO C%d compilers are required to support",
nchars - 1, nchars_max, relevant_std);
}
e_type = wide_flag ? wchar_type_node : char_type_node;
/* Create the array type for the string constant. flag_const_strings /* Create the array type for the string constant. flag_const_strings
says make the string constant an array of const char so that says make the string constant an array of const char so that
copying it to a non-const pointer will get a warning. For C++, copying it to a non-const pointer will get a warning. For C++,
@ -868,6 +880,7 @@ fix_string_type (tree value)
construct the matching unqualified array type first. The C front construct the matching unqualified array type first. The C front
end does not require this, but it does no harm, so we do it end does not require this, but it does no harm, so we do it
unconditionally. */ unconditionally. */
e_type = wide_flag ? wchar_type_node : char_type_node;
i_type = build_index_type (build_int_cst (NULL_TREE, nchars - 1)); i_type = build_index_type (build_int_cst (NULL_TREE, nchars - 1));
a_type = build_array_type (e_type, i_type); a_type = build_array_type (e_type, i_type);
if (flag_const_strings) if (flag_const_strings)

View File

@ -893,6 +893,8 @@ c_common_handle_option (size_t scode, const char *arg, int value)
cpp_opts->warn_endif_labels = 1; cpp_opts->warn_endif_labels = 1;
if (warn_pointer_sign == -1) if (warn_pointer_sign == -1)
warn_pointer_sign = 1; warn_pointer_sign = 1;
if (warn_overlength_strings == -1)
warn_overlength_strings = 1;
break; break;
case OPT_print_objc_runtime_info: case OPT_print_objc_runtime_info:
@ -1018,6 +1020,12 @@ c_common_post_options (const char **pfilename)
if (warn_pointer_sign == -1) if (warn_pointer_sign == -1)
warn_pointer_sign = 0; warn_pointer_sign = 0;
/* -Woverlength-strings is off by default, but is enabled by -pedantic.
It is never enabled in C++, as the minimum limit is not normative
in that standard. */
if (warn_overlength_strings == -1 || c_dialect_cxx ())
warn_overlength_strings = 0;
/* Special format checking options don't work without -Wformat; warn if /* Special format checking options don't work without -Wformat; warn if
they are used. */ they are used. */
if (!warn_format) if (!warn_format)

View File

@ -311,6 +311,10 @@ Wold-style-definition
C ObjC Var(warn_old_style_definition) C ObjC Var(warn_old_style_definition)
Warn if an old-style parameter definition is used Warn if an old-style parameter definition is used
Woverlength-strings
C ObjC C++ ObjC++ Var(warn_overlength_strings) Init(-1)
Warn if a string is longer than the maximum portable length specified by the standard
Woverloaded-virtual Woverloaded-virtual
C++ ObjC++ Var(warn_overloaded_virtual) C++ ObjC++ Var(warn_overloaded_virtual)
Warn about overloaded virtual function names Warn about overloaded virtual function names

58
gcc/configure vendored
View File

@ -6000,6 +6000,7 @@ fi
# We want to use -pedantic, but we don't want warnings about # We want to use -pedantic, but we don't want warnings about
# * 'long long' # * 'long long'
# * variadic macros # * variadic macros
# * overlong strings
# So, we only use -pedantic if we can disable those warnings. # So, we only use -pedantic if we can disable those warnings.
echo "$as_me:$LINENO: checking whether ${CC} accepts -Wno-long-long" >&5 echo "$as_me:$LINENO: checking whether ${CC} accepts -Wno-long-long" >&5
@ -6102,10 +6103,61 @@ fi
echo "$as_me:$LINENO: result: $ac_cv_prog_cc_w_no_variadic_macros" >&5 echo "$as_me:$LINENO: result: $ac_cv_prog_cc_w_no_variadic_macros" >&5
echo "${ECHO_T}$ac_cv_prog_cc_w_no_variadic_macros" >&6 echo "${ECHO_T}$ac_cv_prog_cc_w_no_variadic_macros" >&6
echo "$as_me:$LINENO: checking whether ${CC} accepts -Wno-overlength-strings" >&5
echo $ECHO_N "checking whether ${CC} accepts -Wno-overlength-strings... $ECHO_C" >&6
if test "${ac_cv_prog_cc_w_no_overlength_strings+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
save_CFLAGS="$CFLAGS"
CFLAGS="-Wno-overlength-strings"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_prog_cc_w_no_overlength_strings=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_prog_cc_w_no_overlength_strings=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
CFLAGS="$save_CFLAGS"
fi
echo "$as_me:$LINENO: result: $ac_cv_prog_cc_w_no_overlength_strings" >&5
echo "${ECHO_T}$ac_cv_prog_cc_w_no_overlength_strings" >&6
strict1_warn= strict1_warn=
if test $ac_cv_prog_cc_w_no_long_long = yes \ if test $ac_cv_prog_cc_w_no_long_long = yes \
&& test $ac_cv_prog_cc_w_no_variadic_macros = yes ; then && test $ac_cv_prog_cc_w_no_variadic_macros = yes \
strict1_warn="-pedantic -Wno-long-long -Wno-variadic-macros" && test $ac_cv_prog_cc_w_no_overlength_strings = yes ; then
strict1_warn="-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings"
fi fi
# Add -Wold-style-definition if it's accepted # Add -Wold-style-definition if it's accepted
@ -7468,7 +7520,7 @@ if test "${gcc_cv_prog_makeinfo_modern+set}" = set; then
else else
ac_prog_version=`$MAKEINFO --version 2>&1 | ac_prog_version=`$MAKEINFO --version 2>&1 |
sed -n 's/^.*GNU texinfo.* \([0-9][0-9.]*\).*$/\1/p'` sed -n 's/^.*GNU texinfo.* \([0-9][0-9.]*\).*$/\1/p'`
echo "configure:7471: version of makeinfo is $ac_prog_version" >&5 echo "configure:7523: version of makeinfo is $ac_prog_version" >&5
case $ac_prog_version in case $ac_prog_version in
'') gcc_cv_prog_makeinfo_modern=no;; '') gcc_cv_prog_makeinfo_modern=no;;
4.[4-9]*) 4.[4-9]*)

View File

@ -301,6 +301,7 @@ AC_CHECK_TYPES([__int64], [AC_CHECK_SIZEOF(__int64)])
# We want to use -pedantic, but we don't want warnings about # We want to use -pedantic, but we don't want warnings about
# * 'long long' # * 'long long'
# * variadic macros # * variadic macros
# * overlong strings
# So, we only use -pedantic if we can disable those warnings. # So, we only use -pedantic if we can disable those warnings.
AC_CACHE_CHECK( AC_CACHE_CHECK(
@ -325,10 +326,22 @@ AC_CACHE_CHECK(
CFLAGS="$save_CFLAGS" CFLAGS="$save_CFLAGS"
]) ])
AC_CACHE_CHECK(
[whether ${CC} accepts -Wno-overlength-strings],
[ac_cv_prog_cc_w_no_overlength_strings],
[save_CFLAGS="$CFLAGS"
CFLAGS="-Wno-overlength-strings"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],
[ac_cv_prog_cc_w_no_overlength_strings=yes],
[ac_cv_prog_cc_w_no_overlength_strings=no])
CFLAGS="$save_CFLAGS"
])
strict1_warn= strict1_warn=
if test $ac_cv_prog_cc_w_no_long_long = yes \ if test $ac_cv_prog_cc_w_no_long_long = yes \
&& test $ac_cv_prog_cc_w_no_variadic_macros = yes ; then && test $ac_cv_prog_cc_w_no_variadic_macros = yes \
strict1_warn="-pedantic -Wno-long-long -Wno-variadic-macros" && test $ac_cv_prog_cc_w_no_overlength_strings = yes ; then
strict1_warn="-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings"
fi fi
# Add -Wold-style-definition if it's accepted # Add -Wold-style-definition if it's accepted

View File

@ -238,7 +238,7 @@ Objective-C and Objective-C++ Dialects}.
-Wmain -Wmissing-braces -Wmissing-field-initializers @gol -Wmain -Wmissing-braces -Wmissing-field-initializers @gol
-Wmissing-format-attribute -Wmissing-include-dirs @gol -Wmissing-format-attribute -Wmissing-include-dirs @gol
-Wmissing-noreturn @gol -Wmissing-noreturn @gol
-Wno-multichar -Wnonnull -Wpacked -Wpadded @gol -Wno-multichar -Wnonnull -Woverlength-strings -Wpacked -Wpadded @gol
-Wparentheses -Wpointer-arith -Wno-pointer-to-int-cast @gol -Wparentheses -Wpointer-arith -Wno-pointer-to-int-cast @gol
-Wredundant-decls @gol -Wredundant-decls @gol
-Wreturn-type -Wsequence-point -Wshadow @gol -Wreturn-type -Wsequence-point -Wshadow @gol
@ -3444,6 +3444,21 @@ even when intentional, result in unspecified behavior and are not portable.
Usually these warnings alert that the programmer intended to use Usually these warnings alert that the programmer intended to use
@code{strcmp}. This warning is enabled by @option{-Wall}. @code{strcmp}. This warning is enabled by @option{-Wall}.
@item -Woverlength-strings
@opindex Woverlength-strings
Warn about string constants which are longer than the ``minimum
maximum'' length specified in the C standard. Modern compilers
generally allow string constants which are much longer than the
standard's minimum limit, but very portable programs should avoid
using longer strings.
The limit applies @emph{after} string constant concatenation, and does
not count the trailing NUL@. In C89, the limit was 509 characters; in
C99, it was raised to 4095. C++98 does not specify a normative
minimum maximum, so we do not diagnose overlength strings in C++@.
This option is implied by @option{-pedantic}, and can be disabled with
@option{-Wno-overlength-strings}.
@end table @end table
@node Debugging Options @node Debugging Options

View File

@ -52,9 +52,8 @@ write_header (void)
machine description file. */\n\ machine description file. */\n\
\n\ \n\
#include \"bconfig.h\"\n\ #include \"bconfig.h\"\n\
#include \"system.h\"\n"); #include \"system.h\"\n\
\n\
puts ("\
/* It is necessary, but not entirely safe, to include the headers below\n\ /* It is necessary, but not entirely safe, to include the headers below\n\
in a generator program. As a defensive measure, don't do so when the\n\ in a generator program. As a defensive measure, don't do so when the\n\
table isn't going to have anything in it. */\n\ table isn't going to have anything in it. */\n\
@ -66,23 +65,20 @@ write_header (void)
#undef ENABLE_RTL_CHECKING\n\ #undef ENABLE_RTL_CHECKING\n\
#undef ENABLE_RTL_FLAG_CHECKING\n\ #undef ENABLE_RTL_FLAG_CHECKING\n\
#undef ENABLE_GC_CHECKING\n\ #undef ENABLE_GC_CHECKING\n\
#undef ENABLE_GC_ALWAYS_COLLECT\n"); #undef ENABLE_GC_ALWAYS_COLLECT\n\
\n\
puts ("\
#include \"coretypes.h\"\n\ #include \"coretypes.h\"\n\
#include \"tm.h\"\n\ #include \"tm.h\"\n\
#include \"insn-constants.h\"\n\ #include \"insn-constants.h\"\n\
#include \"rtl.h\"\n\ #include \"rtl.h\"\n\
#include \"tm_p.h\"\n\ #include \"tm_p.h\"\n\
#include \"function.h\"\n"); #include \"function.h\"\n\
\n\
puts ("\
/* Fake - insn-config.h doesn't exist yet. */\n\ /* Fake - insn-config.h doesn't exist yet. */\n\
#define MAX_RECOG_OPERANDS 10\n\ #define MAX_RECOG_OPERANDS 10\n\
#define MAX_DUP_OPERANDS 10\n\ #define MAX_DUP_OPERANDS 10\n\
#define MAX_INSNS_PER_SPLIT 5\n"); #define MAX_INSNS_PER_SPLIT 5\n\
\n\
puts ("\
#include \"regs.h\"\n\ #include \"regs.h\"\n\
#include \"recog.h\"\n\ #include \"recog.h\"\n\
#include \"real.h\"\n\ #include \"real.h\"\n\
@ -134,11 +130,11 @@ write_one_condition (void **slot, void * ARG_UNUSED (dummy))
putchar (*p); putchar (*p);
} }
printf ("\",\n __builtin_constant_p "); fputs ("\",\n __builtin_constant_p ", stdout);
print_c_condition (test->expr); print_c_condition (test->expr);
printf ("\n ? (int) "); fputs ("\n ? (int) ", stdout);
print_c_condition (test->expr); print_c_condition (test->expr);
printf ("\n : -1 },\n"); fputs ("\n : -1 },\n", stdout);
return 1; return 1;
} }
@ -154,9 +150,8 @@ struct c_test\n\
{\n\ {\n\
const char *expr;\n\ const char *expr;\n\
int value;\n\ int value;\n\
};\n"); };\n\
\n\
puts ("\
/* This table lists each condition found in the machine description.\n\ /* This table lists each condition found in the machine description.\n\
Each condition is mapped to its truth value (0 or 1), or -1 if that\n\ Each condition is mapped to its truth value (0 or 1), or -1 if that\n\
cannot be calculated at compile time.\n\ cannot be calculated at compile time.\n\
@ -200,8 +195,8 @@ write_writer (void)
" putchar (*p);\n" " putchar (*p);\n"
" }\n" " }\n"
" puts (\"\\\")\");\n" " puts (\"\\\")\");\n"
" }"); " }\n"
puts (" puts (\"])\");\n" " puts (\"])\");\n"
" fflush (stdout);\n" " fflush (stdout);\n"
"return ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE;\n" "return ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE;\n"
"}"); "}");

View File

@ -1,3 +1,11 @@
2006-01-28 Zack Weinberg <zackw@panix.com>
* gcc.dg/Woverlength-strings.c
* gcc.dg/Woverlength-strings-pedantic-c89.c
* gcc.dg/Woverlength-strings-pedantic-c89-no.c
* gcc.dg/Woverlength-strings-pedantic-c99.c
* gcc.dg/Woverlength-strings-pedantic-c99-no.c: New tests.
2006-01-28 Adam Nemet <anemet@caviumnetworks.com> 2006-01-28 Adam Nemet <anemet@caviumnetworks.com>
* gcc.c-torture/execute/20060127-1.c: New test. * gcc.c-torture/execute/20060127-1.c: New test.

View File

@ -0,0 +1,19 @@
/* -Woverlength-strings complains about string constants which are too long
for the C standard's "minimum maximum" limits. It is off by default,
but implied by -pedantic. */
/* { dg-options "-std=c89 -pedantic -Wno-overlength-strings" } */
#define TEN "xxxxxxxxxx"
#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
/* C89's minimum-maximum is 509. */
const char x510[] = HUN HUN HUN HUN HUN TEN;
/* C99's minimum-maximum is 4095. */
const char x4096[] =
THO THO THO THO /* 4000 */
TEN TEN TEN TEN TEN /* 4050 */
TEN TEN TEN TEN /* 4090 */
"123456";

View File

@ -0,0 +1,19 @@
/* -Woverlength-strings complains about string constants which are too long
for the C standard's "minimum maximum" limits. It is off by default,
but implied by -pedantic. */
/* { dg-options "-std=c89 -pedantic" } */
#define TEN "xxxxxxxxxx"
#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
/* C89's minimum-maximum is 509. */
const char x510[] = HUN HUN HUN HUN HUN TEN; /* { dg-warning "greater than" } */
/* C99's minimum-maximum is 4095. */
const char x4096[] =
THO THO THO THO /* 4000 */
TEN TEN TEN TEN TEN /* 4050 */
TEN TEN TEN TEN /* 4090 */
"123456"; /* { dg-warning "greater than" } */

View File

@ -0,0 +1,19 @@
/* -Woverlength-strings complains about string constants which are too long
for the C standard's "minimum maximum" limits. It is off by default,
but implied by -pedantic. */
/* { dg-options "-std=c99 -pedantic -Wno-overlength-strings" } */
#define TEN "xxxxxxxxxx"
#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
/* C89's minimum-maximum is 509. */
const char x510[] = HUN HUN HUN HUN HUN TEN;
/* C99's minimum-maximum is 4095. */
const char x4096[] =
THO THO THO THO /* 4000 */
TEN TEN TEN TEN TEN /* 4050 */
TEN TEN TEN TEN /* 4090 */
"123456";

View File

@ -0,0 +1,19 @@
/* -Woverlength-strings complains about string constants which are too long
for the C standard's "minimum maximum" limits. It is off by default,
but implied by -pedantic. */
/* { dg-options "-std=c99 -pedantic" } */
#define TEN "xxxxxxxxxx"
#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
/* C89's minimum-maximum is 509. */
const char x510[] = HUN HUN HUN HUN HUN TEN;
/* C99's minimum-maximum is 4095. */
const char x4096[] =
THO THO THO THO /* 4000 */
TEN TEN TEN TEN TEN /* 4050 */
TEN TEN TEN TEN /* 4090 */
"123456"; /* { dg-warning "greater than" } */

View File

@ -0,0 +1,19 @@
/* -Woverlength-strings complains about string constants which are too long
for the C standard's "minimum maximum" limits. It is off by default,
but implied by -pedantic. */
/* { dg-options "" } */
#define TEN "xxxxxxxxxx"
#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
/* C89's minimum-maximum is 509. */
const char x510[] = HUN HUN HUN HUN HUN TEN;
/* C99's minimum-maximum is 4095. */
const char x4096[] =
THO THO THO THO /* 4000 */
TEN TEN TEN TEN TEN /* 4050 */
TEN TEN TEN TEN /* 4090 */
"123456";