From 661f06d2ce9f19b8667b7dd1491a48e368024341 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Mon, 12 Jun 2017 07:16:11 -0400
Subject: [PATCH 16/44] FIXME: WIP

---
 gcc/spellcheck-enchant.c                           | 41 ++++++++++++++---
 .../c-c++-common/Wspellcheck-comments-1.c          | 53 ++++++++++++++++++----
 2 files changed, 78 insertions(+), 16 deletions(-)

diff --git a/gcc/spellcheck-enchant.c b/gcc/spellcheck-enchant.c
index c8fe704..48f2ece 100644
--- a/gcc/spellcheck-enchant.c
+++ b/gcc/spellcheck-enchant.c
@@ -141,52 +141,73 @@ checker::checker (const char *language_tag)
 
       /* Global words.  */
       /* Jargon.  */
+      ADD_WORD ("accessor");
+      ADD_WORD ("allocator");
+      ADD_WORD ("bitfields");
+      ADD_WORD ("boolean");
       ADD_WORD ("checksum");
       ADD_WORD ("checksums");
       ADD_WORD ("constructor");
       ADD_WORD ("constructors");
+      ADD_WORD ("coredump");
       ADD_WORD ("ctor");
       ADD_WORD ("ctors");
       ADD_WORD ("dataflow");
+      ADD_WORD ("deallocation");
+      ADD_WORD ("decl");
       ADD_WORD ("destructor");
       ADD_WORD ("destructors");
+      ADD_WORD ("dir");
       ADD_WORD ("dtor");
       ADD_WORD ("dtors");
       ADD_WORD ("executable");
       ADD_WORD ("executables");
       ADD_WORD ("filename");
       ADD_WORD ("filenames");
+      ADD_WORD ("frontend");
+      ADD_WORD ("indirections");
+      ADD_WORD ("invariants");
       ADD_WORD ("lookup");
       ADD_WORD ("lookups");
       ADD_WORD ("makefile");
       ADD_WORD ("pregenerate");
       ADD_WORD ("pregenerated");
       ADD_WORD ("preprocessor");
+      ADD_WORD ("preprocessors");
+      ADD_WORD ("prototyped");
+      ADD_WORD ("ptr");
+      ADD_WORD ("resizeable");
       ADD_WORD ("runtime");
       ADD_WORD ("signedness");
+      ADD_WORD ("spellchecking");
       ADD_WORD ("stdlib");
       ADD_WORD ("stdlibs");
+      ADD_WORD ("subclasses");
+      ADD_WORD ("subprocesses");
+      ADD_WORD ("typedefs");
       ADD_WORD ("vtable");
 
       /* Names of programs.  */
       ADD_WORD ("autoconf");
       ADD_WORD ("autoheader");
       ADD_WORD ("automake");
+      ADD_WORD ("cpp");
       ADD_WORD ("gcc");
       ADD_WORD ("valgrind");
 
-      /* C/C++ reserved words; preprocessor directives.  */
-      ADD_WORD ("const");
-      ADD_WORD ("enum");
-      ADD_WORD ("namespace");
-      ADD_WORD ("undef");
+      /* C/C++ reserved words; preprocessor directives etc are handled
+	 by checking against identifiers.  */
 
-      /* stdlib names.  */
+      /* stdlib names: many function names are covered by the identifiers check;
+	 here are some extra names (functions and non-functions).  */
       ADD_WORD ("atexit");
-
+      ADD_WORD ("stderr");
+      ADD_WORD ("stdin");
+      ADD_WORD ("stdout");
 
       /* Project-specific word list.  */
       ADD_WORD ("gengtype");
+      ADD_WORD ("gimple");
       ADD_WORD ("gimplification");
       ADD_WORD ("gimplify");
       ADD_WORD ("insn");
@@ -269,6 +290,12 @@ spellcheck_word (const unsigned char *word, size_t len,
   if (maybe_get_identifier_with_length ((const char *)word, len))
     return;
 
+  /* Don't warn for anything that starts with "lib" (including "lib"
+     itself).  */
+  if (len >= 3)
+    if (0 == strncmp ((const char *)word, "lib", 3))
+      return;
+
   if (!checker::singleton->misspelled_p ((const char *)word, len))
     return;
 
diff --git a/gcc/testsuite/c-c++-common/Wspellcheck-comments-1.c b/gcc/testsuite/c-c++-common/Wspellcheck-comments-1.c
index 2a13a04..4735427 100644
--- a/gcc/testsuite/c-c++-common/Wspellcheck-comments-1.c
+++ b/gcc/testsuite/c-c++-common/Wspellcheck-comments-1.c
@@ -74,13 +74,20 @@
 
     Stores HWI-sized integer VAL, treating it as having signedness SGN
                                                         ^~~~~~~~~~
+*/
+
+/* We shouldn't warn for email addresses:
 
-    Define if you want to use __cxa_atexit, rather than atexit, to register C++
-                                                        ^~~~~~
-      (FIXME: should we pregenerate a word list for all of the C and C++
-      stdlibs?  Or use the stuff we've already parsed, do a name lookup?)
+    John Doe <jdoe@example.com>
+              ^~~~
+*/
 
-   Reserved words:
+/* We shouldn't warn for anything that starts with "lib":
+   libc
+   libquadmath
+   libiberty.  */
+
+/* We shouldn't warn for C/C++ reserved words:
 
     Generate from machine description the strings for each enum.
                                                            ^~~~
@@ -89,14 +96,42 @@
                                                                 ^~~~~~~~~
                                                                 spacemen
 
-  Preprocessor directives:
+    const struct
+
+   or for preprocessor directives:
 
     #undef ACCEL_COMPILER
      ^~~~~
 */
 
-/* We shouldn't warn for email addresses:
+/* We shouldn't warn for various names in C/C++ stdlib:
+   atexit
+   printf
+   stdin
+   stdout
+   stderr.  */
+// (FIXME: should we pregenerate a word list for all of the C and C++
+//  stdlibs?  Or use the stuff we've already parsed, do a name lookup?)
+
+
+ /* Define as `fork' if `vfork' does not work.
+               ^~~~~
+
+   PTR			`void *'		`char *'
+
+
+ */
+
+ /* Attribute `nonnull' was valid as of gcc 3.3.  */
+
+/*  This was the case for the `printf' format attribute by itself
+                               ^~~~~~~
+*/
+
+
+/*  create such objects, and they will not be resizeable (so the 'safe'
+                                                                 ^~~~~~
+
+    including the closing ')'.  It takes two arguments: the file position
 
-    John Doe <jdoe@example.com>
-              ^~~~
 */
-- 
1.8.5.3

