From 89a42ac8a1c85ee240df92c7ccd0c973bc95a24c Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Sun, 29 Jan 2006 03:30:47 +0000 Subject: 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 --- gcc/testsuite/gcc.dg/Woverlength-strings.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/Woverlength-strings.c (limited to 'gcc/testsuite/gcc.dg/Woverlength-strings.c') 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"; -- cgit v1.1