This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for bug 28768


This patch fixes bug 28768, a P2 regression for lack of diagnostics on
preprocessing files with unterminated string and character constants
(which are undefined behavior in ISO C) unless those were converted to
tokens.  Because it's essentially the same bug, it also fixes my bug
14634, but whereas that had its regression marker removed, 28768 has
been accepted as a P2 regression.

With this patch, these invalid preprocessing tokens now yield
mandatory pedwarns (the recent situation having been that no
diagnostics were available for them with any option, the old way was
mandatory hard errors).

Because these extensions were never documented (despite my pointing
out the lack of documentation), no documentation changes are required
with this patch.

The libgomp patch is because the libgomp config.h defined
HAVE_CLOCK_GETTIME to a value with a single ' that was intended to be
a comment rather than a macro definition.

Bootstrapped with no regressions on i686-pc-linux-gnu.  OK to commit
to mainline?  (I don't consider this sort of adding of pedwarns
suitable for past release branches that have already had releases.)

libcpp:
2006-09-13  Joseph S. Myers  <joseph@codesourcery.com>

	PR c/28768
	PR preprocessor/14634
	* lex.c (lex_string): Pedwarn for unterminated literals.

libgomp:
2006-09-13  Joseph S. Myers  <joseph@codesourcery.com>

	PR c/28768
	PR preprocessor/14634
	* configure.ac (HAVE_CLOCK_GETTIME): Add missing second argument
	to AC_DEFINE.
	* configure: Regenerate.

gcc/testsuite:
2006-09-13  Joseph S. Myers  <joseph@codesourcery.com>

	PR c/28768
	PR preprocessor/14634
	* gcc.dg/cpp/include2.c, gcc.dg/cpp/macspace1.c,
	gcc.dg/cpp/macspace2.c, gcc.dg/cpp/multiline.c,
	gcc.dg/cpp/trad/literals-2.c: Update expected diagnostics.

diff -rupN GCC.orig/gcc/testsuite/gcc.dg/cpp/include2.c GCC/gcc/testsuite/gcc.dg/cpp/include2.c
--- GCC.orig/gcc/testsuite/gcc.dg/cpp/include2.c	2005-10-28 23:28:40.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/cpp/include2.c	2006-09-12 23:43:39.000000000 +0000
@@ -13,4 +13,4 @@
 /* These error is No such file or directory, just once.  However, this
    message is locale-dependent, so don't test for it.  */
 /* { dg-error "silly" "" { target *-*-* } 10 } */
-
+/* { dg-error "missing" "" { target *-*-* } 11 } */
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/cpp/macspace1.c GCC/gcc/testsuite/gcc.dg/cpp/macspace1.c
--- GCC.orig/gcc/testsuite/gcc.dg/cpp/macspace1.c	2005-10-28 23:28:40.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/cpp/macspace1.c	2006-09-13 00:19:09.000000000 +0000
@@ -59,3 +59,5 @@
 #define ag"abc"		/* { dg-warning "missing whitespace" } */
 
 int dummy;
+/* { dg-error "missing terminating" "" { target *-*-* } 6 } */
+/* { dg-error "missing terminating" "" { target *-*-* } 10 } */
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/cpp/macspace2.c GCC/gcc/testsuite/gcc.dg/cpp/macspace2.c
--- GCC.orig/gcc/testsuite/gcc.dg/cpp/macspace2.c	2005-10-28 23:28:40.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/cpp/macspace2.c	2006-09-13 00:19:18.000000000 +0000
@@ -59,3 +59,5 @@
 #define ag"abc"		/* { dg-error "requires whitespace" } */
 
 int dummy;
+/* { dg-error "missing terminating" "" { target *-*-* } 6 } */
+/* { dg-error "missing terminating" "" { target *-*-* } 10 } */
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/cpp/multiline.c GCC/gcc/testsuite/gcc.dg/cpp/multiline.c
--- GCC.orig/gcc/testsuite/gcc.dg/cpp/multiline.c	2005-10-28 23:28:40.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/cpp/multiline.c	2006-09-12 23:46:58.000000000 +0000
@@ -19,5 +19,7 @@ L"line 1
 /* Nowhere in the output of this file should there be a blank line.
    We check for that in the .i file.
    { dg-final { scan-file-not multiline.i "(^|\\n)\\n" } } */
-/* { dg-bogus "missing term" "multiline strings" { target *-*-* } 11 } */
-/* { dg-bogus "warning" "warning in place of error" { target *-*-* } 15 } */
+/* { dg-warning "missing term" "multiline strings" { target *-*-* } 11 } */
+/* { dg-warning "missing term" "multiline strings" { target *-*-* } 14 } */
+/* { dg-warning "missing term" "multiline strings" { target *-*-* } 15 } */
+/* { dg-warning "missing term" "multiline strings" { target *-*-* } 18 } */
diff -rupN GCC.orig/gcc/testsuite/gcc.dg/cpp/trad/literals-2.c GCC/gcc/testsuite/gcc.dg/cpp/trad/literals-2.c
--- GCC.orig/gcc/testsuite/gcc.dg/cpp/trad/literals-2.c	2005-10-28 23:28:40.000000000 +0000
+++ GCC/gcc/testsuite/gcc.dg/cpp/trad/literals-2.c	2006-09-12 23:42:08.000000000 +0000
@@ -2,7 +2,7 @@
    recognized.  */
 
 /* { dg-do preprocess } */
-
+/* { dg-error "missing terminating" "bad charconst" { target *-*-* } 7 } */
 /* { dg-error "not valid" "bad charconst" { target *-*-* } 7 } */
 #if 'x
 #endif
diff -rupN GCC.orig/libcpp/lex.c GCC/libcpp/lex.c
--- GCC.orig/libcpp/lex.c	2006-08-16 11:27:36.000000000 +0000
+++ GCC/libcpp/lex.c	2006-09-12 19:45:14.000000000 +0000
@@ -646,6 +646,10 @@ lex_string (cpp_reader *pfile, cpp_token
     cpp_error (pfile, CPP_DL_WARNING,
 	       "null character(s) preserved in literal");
 
+  if (type == CPP_OTHER && CPP_OPTION (pfile, lang) != CLK_ASM)
+    cpp_error (pfile, CPP_DL_PEDWARN, "missing terminating %c character",
+	       (int) terminator);
+
   pfile->buffer->cur = cur;
   create_literal (pfile, token, base, cur - base, type);
 }
diff -rupN GCC.orig/libgomp/configure.ac GCC/libgomp/configure.ac
--- GCC.orig/libgomp/configure.ac	2006-07-22 18:49:01.000000000 +0000
+++ GCC/libgomp/configure.ac	2006-09-12 22:11:15.000000000 +0000
@@ -227,7 +227,7 @@ esac
 if test $ac_cv_func_clock_gettime = no; then
   AC_CHECK_LIB(rt, clock_gettime,
     [LIBS="-lrt $LIBS"
-     AC_DEFINE(HAVE_CLOCK_GETTIME,
+     AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
 	       [Define to 1 if you have the `clock_gettime' function.])])
 fi
 

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]