From 60f60799679ddb23b74f56d8210d42c32799f15c Mon Sep 17 00:00:00 2001
From: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 6 Jul 1998 21:53:23 +0000
Subject: [PATCH]         * c-decl.c: Add warn_multichar.        
 (c_decode_option): Handle -Wno-multichar.         * c-lex.c (yylex): Check
 it.         * c-tree.h: Declare it.         * toplev.c (lang_options): Add
 it.         * invoke.texi: Document it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@20968 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog   | 9 +++++++++
 gcc/c-decl.c    | 8 ++++++++
 gcc/c-lex.c     | 2 +-
 gcc/c-tree.h    | 4 ++++
 gcc/invoke.texi | 7 ++++++-
 gcc/toplev.c    | 2 ++
 6 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9f0c949f7171..76750938efc1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+Mon Jul  6 22:50:48 1998  Jason Merrill  <jason@yorick.cygnus.com>
+
+	* c-decl.c: Add warn_multichar.
+	(c_decode_option): Handle -Wno-multichar.
+	* c-lex.c (yylex): Check it.
+	* c-tree.h: Declare it.
+	* toplev.c (lang_options): Add it.
+	* invoke.texi: Document it.
+
 Mon Jul  6 22:47:55 1998  J"orn Rennecke <amylaar@cygnus.co.uk>
 
 	* gcse.c (hash_scan_insn): New argument IN_LIBCALL_BLOCK.  Changed
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 5465e4027df5..9901db80e68d 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -577,6 +577,10 @@ int warn_unknown_pragmas = 0; /* Tri state variable.  */
 
 int warn_sign_compare = -1;
 
+/* Nonzero means warn about use of multicharacter literals.  */
+
+int warn_multichar = 1;
+
 /* Nonzero means `$' can be in an identifier.  */
 
 #ifndef DOLLARS_IN_IDENTIFIERS
@@ -792,6 +796,10 @@ c_decode_option (argc, argv)
     warn_sign_compare = 1;
   else if (!strcmp (p, "-Wno-sign-compare"))
     warn_sign_compare = 0;
+  else if (!strcmp (p, "-Wmultichar"))
+    warn_multichar = 1;
+  else if (!strcmp (p, "-Wno-multichar"))
+    warn_multichar = 0;
   else if (!strcmp (p, "-Wunknown-pragmas"))
     /* Set to greater than 1, so that even unknown pragmas in system
        headers will be warned about.  */
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index c33ade528225..f82ad761d318 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -1872,7 +1872,7 @@ yylex ()
 	    num_chars = max_chars;
 	    error ("character constant too long");
 	  }
-	else if (num_chars != 1 && ! flag_traditional)
+	else if (num_chars != 1 && ! flag_traditional && warn_multichar)
 	  warning ("multi-character character constant");
 
 	/* If char type is signed, sign-extend the constant.  */
diff --git a/gcc/c-tree.h b/gcc/c-tree.h
index 3a9f4f83b786..7605cfe2e519 100644
--- a/gcc/c-tree.h
+++ b/gcc/c-tree.h
@@ -505,6 +505,10 @@ extern int warn_missing_braces;
 
 extern int warn_sign_compare;
 
+/* Warn about multicharacter constants.  */
+
+extern int warn_multichar;
+
 /* Nonzero means we are reading code that came from a system header file.  */
 
 extern int system_header_p;
diff --git a/gcc/invoke.texi b/gcc/invoke.texi
index a07fcf60a542..5bfac524c5c1 100644
--- a/gcc/invoke.texi
+++ b/gcc/invoke.texi
@@ -122,7 +122,7 @@ in the following sections.
 -Wimplicit-function-declaration  -Wimport
 -Werror-implicit-function-declaration  -Winline
 -Wlarger-than-@var{len}  -Wmain  -Wmissing-declarations
--Wmissing-prototypes  -Wnested-externs  -Wno-import  
+-Wmissing-prototypes  -Wmultichar  -Wnested-externs  -Wno-import  
 -Wold-style-cast  -Woverloaded-virtual  -Wparentheses
 -Wpointer-arith  -Wredundant-decls  -Wreorder  -Wreturn-type
 -Wshadow  -Wsign-compare  -Wstrict-prototypes  -Wswitch
@@ -1287,6 +1287,11 @@ Same as @samp{-Wimplicit-int} and @samp{-Wimplicit-function-}@*
 Warn if the type of @samp{main} is suspicious.  @samp{main} should be a
 function with external linkage, returning int, taking either zero
 arguments, two, or three arguments of appropriate types.
+
+@item -Wmultichar
+Warn if a multicharacter constant (@samp{'FOOF'}) is used.  Usually they
+indicate a typo in the user's code, as they have implementation-defined
+values, and should not be used in portable code.
   
 @item -Wparentheses
 Warn if parentheses are omitted in certain contexts, such
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 6bc76632a2a5..1126a4af2fcb 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -872,6 +872,8 @@ char *lang_options[] =
   "-Wno-missing-declarations",
   "-Wmissing-prototypes",
   "-Wno-missing-prototypes",
+  "-Wmultichar",
+  "-Wno-multichar",
   "-Wnested-externs",
   "-Wno-nested-externs",
   "-Wparentheses",
-- 
GitLab