c-common.c (combine_strings): When the ISO C standard specifies the maximum length of a string...

* c-common.c (combine_strings): When the ISO C standard specifies
 	the maximum length of a string, it doesn't include the trailing
 	zero byte.

	* gcc.dg/cpp/if-6.c: New testcase.

From-SVN: r37961
This commit is contained in:
Geoffrey Keating 2000-12-02 22:32:15 +00:00 committed by Geoffrey Keating
parent b43db0b3c0
commit 690c96c8bf
4 changed files with 14 additions and 5 deletions

View File

@ -1,4 +1,8 @@
2000-12-01 Geoffrey Keating <geoffk@redhat.com>
2000-12-02 Geoffrey Keating <geoffk@redhat.com>
* c-common.c (combine_strings): When the ISO C standard specifies
the maximum length of a string, it doesn't include the trailing
zero byte.
* cpplib.c (do_ifdef): Add check_eol() call.
(do_ifndef): Likewise.

View File

@ -468,9 +468,9 @@ combine_strings (strings)
/* Compute the number of elements, for the array type. */
nchars = wide_flag ? length / wchar_bytes : length;
if (pedantic && nchars > nchars_max && c_language == clk_c)
if (pedantic && nchars - 1 > nchars_max && c_language == clk_c)
pedwarn ("string length `%d' is greater than the minimum length `%d' ISO C%d is required to support",
nchars, nchars_max, flag_isoc99 ? 99 : 89);
nchars - 1, nchars_max, flag_isoc99 ? 99 : 89);
/* Create the array type for the string constant.
-Wwrite-strings says make the string constant an array of const char

View File

@ -1,4 +1,6 @@
2000-12-01 Geoffrey Keating <geoffk@redhat.com>
2000-12-02 Geoffrey Keating <geoffk@redhat.com>
* gcc.dg/cpp/if-6.c: New testcase.
* gcc.dg/20001201-1.c: New testcase.

View File

@ -0,0 +1,3 @@
/* { dg-do preprocess } */
#ifdef foo bar /* { dg-error "extra tokens" "tokens after #ifdef" } */
#endif