aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog33
-rw-r--r--gcc/Makefile.in10
-rw-r--r--gcc/c-common.c23
-rw-r--r--gcc/c-opts.c8
-rw-r--r--gcc/c.opt4
-rwxr-xr-xgcc/configure58
-rw-r--r--gcc/configure.ac17
-rw-r--r--gcc/doc/invoke.texi17
-rw-r--r--gcc/genconditions.c35
-rw-r--r--gcc/testsuite/ChangeLog48
-rw-r--r--gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-no.c19
-rw-r--r--gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89.c19
-rw-r--r--gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-no.c19
-rw-r--r--gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99.c19
-rw-r--r--gcc/testsuite/gcc.dg/Woverlength-strings.c19
15 files changed, 285 insertions, 63 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b9900bf..f40c031 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,12 +1,33 @@
+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>
* combine.c (simplify_comparison <AND>): Check
TRULY_NOOP_TRUNCATION before start using a subreg.
-
- * config/mips/mips.md (*branch_zero<mode>,
- *branch_zero<mode>_inverted, *branch_equality<mode>,
- *branch_equality<mode>_inverted, *branch_equality<mode>_mips16):
- Remove mode check from comparisons.
+
+ * config/mips/mips.md (*branch_zero<mode>,
+ *branch_zero<mode>_inverted, *branch_equality<mode>,
+ *branch_equality<mode>_inverted, *branch_equality<mode>_mips16):
+ Remove mode check from comparisons.
2006-01-28 Kenneth Zadeck <zadeck@naturalbridge.com>
@@ -72,7 +93,7 @@
2006-01-27 Daniel Berlin <dberlin@dberlin.org>
Kenneth Zadeck <zadeck@naturalbridge.com>
- PR rtl-optimization/24762
+ PR rtl-optimization/24762
* doc/tm.texi: Added TARGET_EXTRA_LIVE_ON_ENTRY.
* targhooks.c (hook_void_bitmap): New hook prototype.
* targhoohs.h (hook_void_bitmap): Ditto.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index e28677c..40c18a1 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -177,7 +177,8 @@ LOOSE_WARN = -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
STRICT_WARN = @strict1_warn@
WERROR_FLAGS = @WERROR@
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
# "extern" tags in header files.
@@ -195,11 +196,8 @@ VALGRIND_DRIVER_DEFINES = @valgrind_path_defines@
build-warn = $(STRICT_WARN)
GCC_WARN_CFLAGS = $(LOOSE_WARN) $($(@D)-warn) $(NOCOMMON_FLAG) $($@-warn)
-# These files are to have -Werror bypassed in stage2:
-# These are very hard to completely clean due to target complexities.
-gcc.o-warn = -Wno-error
-insn-automata.o-warn = -Wno-error
-build/gencondmd.o-warn = -Wno-error
+# These files are to have specific diagnostics suppressed, or are not to
+# be subject to -Werror:
# Bison-1.75 output often yields (harmless) -Wtraditional warnings
build/gengtype-yacc.o-warn = -Wno-error
# flex output may yield harmless "no previous prototype" warnings
diff --git a/gcc/c-common.c b/gcc/c-common.c
index fe99dfb..5be3363 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -844,7 +844,6 @@ fix_string_type (tree value)
{
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 nchars_max = flag_isoc99 ? 4095 : 509;
int length = TREE_STRING_LENGTH (value);
int nchars;
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. */
nchars = wide_flag ? length / wchar_bytes : length;
- if (pedantic && nchars - 1 > nchars_max && !c_dialect_cxx ())
- pedwarn ("string length %qd is greater than the length %qd ISO C%d compilers are required to support",
- nchars - 1, nchars_max, flag_isoc99 ? 99 : 89);
+ /* C89 2.2.4.1, C99 5.2.4.1 (Translation limits). The analogous
+ limit in C++98 Annex B is very large (65536) and is not normative,
+ 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
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++,
@@ -868,6 +880,7 @@ fix_string_type (tree value)
construct the matching unqualified array type first. The C front
end does not require this, but it does no harm, so we do it
unconditionally. */
+ e_type = wide_flag ? wchar_type_node : char_type_node;
i_type = build_index_type (build_int_cst (NULL_TREE, nchars - 1));
a_type = build_array_type (e_type, i_type);
if (flag_const_strings)
diff --git a/gcc/c-opts.c b/gcc/c-opts.c
index d2df860..8c5827a 100644
--- a/gcc/c-opts.c
+++ b/gcc/c-opts.c
@@ -893,6 +893,8 @@ c_common_handle_option (size_t scode, const char *arg, int value)
cpp_opts->warn_endif_labels = 1;
if (warn_pointer_sign == -1)
warn_pointer_sign = 1;
+ if (warn_overlength_strings == -1)
+ warn_overlength_strings = 1;
break;
case OPT_print_objc_runtime_info:
@@ -1018,6 +1020,12 @@ c_common_post_options (const char **pfilename)
if (warn_pointer_sign == -1)
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
they are used. */
if (!warn_format)
diff --git a/gcc/c.opt b/gcc/c.opt
index 44a47ed..4ce9b9f 100644
--- a/gcc/c.opt
+++ b/gcc/c.opt
@@ -311,6 +311,10 @@ Wold-style-definition
C ObjC Var(warn_old_style_definition)
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
C++ ObjC++ Var(warn_overloaded_virtual)
Warn about overloaded virtual function names
diff --git a/gcc/configure b/gcc/configure
index 7f35799..14ee2ba 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -6000,6 +6000,7 @@ fi
# We want to use -pedantic, but we don't want warnings about
# * 'long long'
# * variadic macros
+# * overlong strings
# So, we only use -pedantic if we can disable those warnings.
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 "${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=
if test $ac_cv_prog_cc_w_no_long_long = yes \
- && test $ac_cv_prog_cc_w_no_variadic_macros = yes ; then
- strict1_warn="-pedantic -Wno-long-long -Wno-variadic-macros"
+ && test $ac_cv_prog_cc_w_no_variadic_macros = yes \
+ && test $ac_cv_prog_cc_w_no_overlength_strings = yes ; then
+ strict1_warn="-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings"
fi
# Add -Wold-style-definition if it's accepted
@@ -7468,7 +7520,7 @@ if test "${gcc_cv_prog_makeinfo_modern+set}" = set; then
else
ac_prog_version=`$MAKEINFO --version 2>&1 |
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
'') gcc_cv_prog_makeinfo_modern=no;;
4.[4-9]*)
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 03964d6..dd3823f 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -301,6 +301,7 @@ AC_CHECK_TYPES([__int64], [AC_CHECK_SIZEOF(__int64)])
# We want to use -pedantic, but we don't want warnings about
# * 'long long'
# * variadic macros
+# * overlong strings
# So, we only use -pedantic if we can disable those warnings.
AC_CACHE_CHECK(
@@ -325,10 +326,22 @@ AC_CACHE_CHECK(
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=
if test $ac_cv_prog_cc_w_no_long_long = yes \
- && test $ac_cv_prog_cc_w_no_variadic_macros = yes ; then
- strict1_warn="-pedantic -Wno-long-long -Wno-variadic-macros"
+ && test $ac_cv_prog_cc_w_no_variadic_macros = yes \
+ && test $ac_cv_prog_cc_w_no_overlength_strings = yes ; then
+ strict1_warn="-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings"
fi
# Add -Wold-style-definition if it's accepted
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 8301a0a..d8f69e8 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -238,7 +238,7 @@ Objective-C and Objective-C++ Dialects}.
-Wmain -Wmissing-braces -Wmissing-field-initializers @gol
-Wmissing-format-attribute -Wmissing-include-dirs @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
-Wredundant-decls @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
@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
@node Debugging Options
diff --git a/gcc/genconditions.c b/gcc/genconditions.c
index bc4bfd5..ae9a67e 100644
--- a/gcc/genconditions.c
+++ b/gcc/genconditions.c
@@ -52,9 +52,8 @@ write_header (void)
machine description file. */\n\
\n\
#include \"bconfig.h\"\n\
-#include \"system.h\"\n");
-
- puts ("\
+#include \"system.h\"\n\
+\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\
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_FLAG_CHECKING\n\
#undef ENABLE_GC_CHECKING\n\
-#undef ENABLE_GC_ALWAYS_COLLECT\n");
-
- puts ("\
+#undef ENABLE_GC_ALWAYS_COLLECT\n\
+\n\
#include \"coretypes.h\"\n\
#include \"tm.h\"\n\
#include \"insn-constants.h\"\n\
#include \"rtl.h\"\n\
#include \"tm_p.h\"\n\
-#include \"function.h\"\n");
-
- puts ("\
+#include \"function.h\"\n\
+\n\
/* Fake - insn-config.h doesn't exist yet. */\n\
#define MAX_RECOG_OPERANDS 10\n\
#define MAX_DUP_OPERANDS 10\n\
-#define MAX_INSNS_PER_SPLIT 5\n");
-
- puts ("\
+#define MAX_INSNS_PER_SPLIT 5\n\
+\n\
#include \"regs.h\"\n\
#include \"recog.h\"\n\
#include \"real.h\"\n\
@@ -134,11 +130,11 @@ write_one_condition (void **slot, void * ARG_UNUSED (dummy))
putchar (*p);
}
- printf ("\",\n __builtin_constant_p ");
+ fputs ("\",\n __builtin_constant_p ", stdout);
print_c_condition (test->expr);
- printf ("\n ? (int) ");
+ fputs ("\n ? (int) ", stdout);
print_c_condition (test->expr);
- printf ("\n : -1 },\n");
+ fputs ("\n : -1 },\n", stdout);
return 1;
}
@@ -154,9 +150,8 @@ struct c_test\n\
{\n\
const char *expr;\n\
int value;\n\
-};\n");
-
- puts ("\
+};\n\
+\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\
cannot be calculated at compile time.\n\
@@ -200,8 +195,8 @@ write_writer (void)
" putchar (*p);\n"
" }\n"
" puts (\"\\\")\");\n"
- " }");
- puts (" puts (\"])\");\n"
+ " }\n"
+ " puts (\"])\");\n"
" fflush (stdout);\n"
"return ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE;\n"
"}");
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2be6012..a5aba92 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,14 @@
+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>
- * gcc.c-torture/execute/20060127-1.c: New test.
+ * gcc.c-torture/execute/20060127-1.c: New test.
2006-01-28 Mark Mitchell <mark@codesourcery.com>
@@ -32,12 +40,12 @@
2006-01-26 Laurent GUERBY <laurent@guerby.net>
- PR ada/21317
- * ada/acats/support/impdef.a: Add One_Long_Second.
- * ada/acats/tests/c9/c94025.a: Use One_Long_Second.
- * ada/acats/tests/c9/c94026.a: Likewise.
- * ada/acats/tests/c9/c97305c.ada: Likewise.
- * ada/acats/tests/c9/c99004a.ada: Likewise.
+ PR ada/21317
+ * ada/acats/support/impdef.a: Add One_Long_Second.
+ * ada/acats/tests/c9/c94025.a: Use One_Long_Second.
+ * ada/acats/tests/c9/c94026.a: Likewise.
+ * ada/acats/tests/c9/c97305c.ada: Likewise.
+ * ada/acats/tests/c9/c99004a.ada: Likewise.
2005-01-26 Paul Thomas <pault@gcc.gnu.org>
@@ -68,7 +76,7 @@
PR C/25861
* gcc.c-torture/compile/pr25861.c: New test.
-
+
2006-01-26 Paul Brook <paul@codesourcery.com>
* gcc.dg/compat/struct-layout-1.exp: Pass -e to generator program
@@ -124,7 +132,7 @@
* gfortran.dg/read_eof_1.f90: Rename from read_eof.f90.
* gfortran.dg/read_eof_2.f90: New test.
* gfortran.dg/read_eof_3.f90: New test.
-
+
2006-01-24 Andrew Pinski <pinskia@physics.uc.edu>
PR tree-opt/25860
@@ -231,8 +239,8 @@
2006-01-20 Dirk Mueller <dmueller@suse.com>
- PR c++/5520
- * g++.dg/warn/empty-body.C: New.
+ PR c++/5520
+ * g++.dg/warn/empty-body.C: New.
2006-01-19 Mark Mitchell <mark@codesourcery.com>
@@ -482,7 +490,7 @@
to LD_LIBRARY_PATH.
2006-01-16 Eric Botcazou <ebotcazou@adacore.com>
- Andrew Pinski <pinskia@physics.uc.edu>
+ Andrew Pinski <pinskia@physics.uc.edu>
* gcc.dg/minmax-1.c: New test.
@@ -674,15 +682,15 @@
2006-01-11 Paolo Bonzini <bonzini@gnu.org>
- PR tree-optimization/23109
- PR tree-optimization/23948
- PR tree-optimization/24123
+ PR tree-optimization/23109
+ PR tree-optimization/23948
+ PR tree-optimization/24123
- * gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
- gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
- gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
- g++.dg/tree-ssa/pr23948.C: New testcases.
- * gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
+ * gcc.dg/tree-ssa/recip-3.c, gcc.dg/tree-ssa/recip-4.c,
+ gcc.dg/tree-ssa/recip-5.c, gcc.dg/tree-ssa/recip-6.c,
+ gcc.dg/tree-ssa/recip-7.c, gcc.dg/tree-ssa/pr23109.c,
+ g++.dg/tree-ssa/pr23948.C: New testcases.
+ * gcc.dg/tree-ssa/recip-2.c, gcc.dg/tree-ssa/pr23234.c: Provide
three divisions in order to do the optimization.
2006-01-11 Zdenek Dvorak <dvorakz@suse.cz>
diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-no.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-no.c
new file mode 100644
index 0000000..a2ccbdd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-no.c
@@ -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";
diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89.c
new file mode 100644
index 0000000..9370acf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89.c
@@ -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" } */
diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-no.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-no.c
new file mode 100644
index 0000000..a44a214
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-no.c
@@ -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";
diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99.c
new file mode 100644
index 0000000..e7f5121
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99.c
@@ -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" } */
diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings.c b/gcc/testsuite/gcc.dg/Woverlength-strings.c
new file mode 100644
index 0000000..d02e18e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Woverlength-strings.c
@@ -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";