This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
4.0 patch for warnings becoming errors with patch for bug 17964
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 17 Nov 2005 21:10:56 +0000 (UTC)
- Subject: 4.0 patch for warnings becoming errors with patch for bug 17964
My patch to fix bug 17964 as a side-effect turned pedwarns from string
interpretation (e.g. for unknown escape sequences such as "\q" or
"\.") into errors by default for C++, because previously the
diagnostics used cpplib's notion of pedantic_errors and now they use
the front end's.
In principle I think the two notions should be consistent and I've
filed bug 24924 for the inconsistency; I think any mainline change
should be in the direction of turning the other cpp pedwarns into
errors by default for C++. However, on a release branch it's a bad
idea to increase the strictness of the compiler in this way. The
following patch restores these diagnostics to warnings by default on
4.0 branch. Bootstrapped with no regressions on i686-pc-linux-gnu.
OK to commit to 4.0 branch, and to commit a variant of the testcase
which tests that the diagnostic is a hard error instead of a warning
to mainline?
libcpp:
2005-11-17 Joseph S. Myers <joseph@codesourcery.com>
* errors.c (cpp_error): Use cpplib's notion of pedantic_errors
when passing diagnostics to front end.
gcc/testsuite:
2005-11-17 Joseph S. Myers <joseph@codesourcery.com>
* g++.dg/cpp/string-2.C: New test.
diff -rupN GCC.orig/gcc/testsuite/g++.dg/cpp/string-2.C GCC/gcc/testsuite/g++.dg/cpp/string-2.C
--- GCC.orig/gcc/testsuite/g++.dg/cpp/string-2.C 1970-01-01 00:00:00.000000000 +0000
+++ GCC/gcc/testsuite/g++.dg/cpp/string-2.C 2005-11-17 20:10:57.000000000 +0000
@@ -0,0 +1,7 @@
+// Test diagnostics for interpreting strings: should not be an error
+// by default (4.0).
+// Origin: Joseph Myers <joseph@codesourcery.com>
+// { dg-do compile }
+// { dg-options "" }
+
+const char *s = "\q"; // { dg-warning "warning: unknown escape sequence" }
diff -rupN GCC.orig/libcpp/errors.c GCC/libcpp/errors.c
--- GCC.orig/libcpp/errors.c 2005-11-04 01:19:44.000000000 +0000
+++ GCC/libcpp/errors.c 2005-11-17 20:09:29.000000000 +0000
@@ -141,7 +141,16 @@ cpp_error (cpp_reader * pfile, int level
va_start (ap, msgid);
if (CPP_OPTION (pfile, client_diagnostic))
- pfile->cb.error (pfile, level, _(msgid), &ap);
+ {
+ /* Versions up to 4.0.2 used cpplib's notion of pedantic_errors
+ rather than the front end's, so preserve this for the 4.0
+ branch. */
+ if (level == CPP_DL_PEDWARN)
+ level = (CPP_OPTION (pfile, pedantic_errors)
+ ? CPP_DL_ERROR
+ : CPP_DL_WARNING);
+ pfile->cb.error (pfile, level, _(msgid), &ap);
+ }
else
{
if (CPP_OPTION (pfile, traditional))
--
Joseph S. Myers http://www.srcf.ucam.org/~jsm28/gcc/
jsm@polyomino.org.uk (personal mail)
joseph@codesourcery.com (CodeSourcery mail)
jsm28@gcc.gnu.org (Bugzilla assignments and CCs)