]> gcc.gnu.org Git - gcc.git/commitdiff
c-common.c (combine_strings): When the ISO C standard specifies the maximum length...
authorGeoffrey Keating <geoffk@redhat.com>
Sat, 2 Dec 2000 22:32:15 +0000 (22:32 +0000)
committerGeoffrey Keating <geoffk@gcc.gnu.org>
Sat, 2 Dec 2000 22:32:15 +0000 (22:32 +0000)
* 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

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/if-6.c [new file with mode: 0644]

index 6a08a83cda5a04f964a1cca20f6f5303080a5176..11b01ab71dce6e152daddada14e918347599d5cc 100644 (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.
index 465bdbe45516adbe98c5d333f6188b7f7279a306..6e3394539a1fdfa1ee8880c30a67db7ba25f1f03 100644 (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
index 367f5d84bf14d87e2b285af360f3fe0a3b516219..00397daa088842c19fd85dec3ae17ce6e08d9b16 100644 (file)
@@ -1,7 +1,9 @@
-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.
-       
+
 2000-12-02  Neil Booth  <neilb@earthling.net>
 
         * g++.old-deja/g++.other/externC4.C,
diff --git a/gcc/testsuite/gcc.dg/cpp/if-6.c b/gcc/testsuite/gcc.dg/cpp/if-6.c
new file mode 100644 (file)
index 0000000..1f23d2c
--- /dev/null
@@ -0,0 +1,3 @@
+/* { dg-do preprocess } */
+#ifdef foo bar  /* { dg-error "extra tokens" "tokens after #ifdef" } */
+#endif
This page took 0.113451 seconds and 5 git commands to generate.