]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Preprocessor] small cleanups
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Aug 2019 18:43:37 +0000 (18:43 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Aug 2019 18:43:37 +0000 (18:43 +0000)
https://gcc.gnu.org/ml/gcc-patches/2019-08/msg01904.html
* directives-only.c (_cpp_preprocess_dir_only): Use false, not
zero for _cpp_handle_directive call.
* directives.c (_cpp_handle_directive): Indented is bool.
* files.c (struct _cpp_file): Make bools 1 bit bitfields.
* internal.h (enum include_type): Reformat and comment.
(struct cpp_buffer): Make flags 1 bit bitfields.
(_cpp_handle_directive): Indented is bool.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274999 138bc75d-0d04-0410-961f-82ee72b054a4

libcpp/ChangeLog
libcpp/directives-only.c
libcpp/directives.c
libcpp/files.c
libcpp/internal.h

index c6e8e04b46e011e31edcc868e04bebf8630eaa49..61d91acb2d78fc54bf1fd964ee39cbf5da9abec5 100644 (file)
@@ -1,3 +1,13 @@
+2019-08-28  Nathan Sidwell  <nathan@acm.org>
+
+       * directives-only.c (_cpp_preprocess_dir_only): Use false, not
+       zero for _cpp_handle_directive call.
+       * directives.c (_cpp_handle_directive): Indented is bool.
+       * files.c (struct _cpp_file): Make bools 1 bit bitfields.
+       * internal.h (enum include_type): Reformat and comment.
+       (struct cpp_buffer): Make flags 1 bit bitfields.
+       (_cpp_handle_directive): Indented is bool.
+
 2019-07-09  Martin Sebor  <msebor@redhat.com>
 
        * include/line-map.h: Change class-key from class to struct and vice
index 847225af825334eca4000faaa770946cc26e0b5d..fae3b5b4ba499345f5c30727fbba4b9ddffe136c 100644 (file)
@@ -101,7 +101,7 @@ _cpp_preprocess_dir_only (cpp_reader *pfile,
            /* Ensure proper column numbering for generated error messages. */
            buffer->line_base -= col - 1;
 
-           _cpp_handle_directive (pfile, 0 /* ignore indented */);
+           _cpp_handle_directive (pfile, false /* ignore indented */);
 
            /* Sanitize the line settings.  Duplicate #include's can mess
               things up. */
index ddf8979d5139cf14c045cf891bfe443f5d5a78aa..48271e1700ecf2d9fb89457b8ceb9fdd187ced5f 100644 (file)
@@ -406,13 +406,13 @@ directive_diagnostics (cpp_reader *pfile, const directive *dir, int indented)
     }
 }
 
-/* Check if we have a known directive.  INDENTED is nonzero if the
+/* Check if we have a known directive.  INDENTED is true if the
    '#' of the directive was indented.  This function is in this file
    to save unnecessarily exporting dtable etc. to lex.c.  Returns
    nonzero if the line of tokens has been handled, zero if we should
    continue processing the line.  */
 int
-_cpp_handle_directive (cpp_reader *pfile, int indented)
+_cpp_handle_directive (cpp_reader *pfile, bool indented)
 {
   const directive *dir = 0;
   const cpp_token *dname;
index 6ef6d07b89767bb98b71042521ae774e621d5893..30c0cf255194b79cad3660049a751d9361a1f068 100644 (file)
@@ -98,19 +98,19 @@ struct _cpp_file
   unsigned short stack_count;
 
   /* If opened with #import or contains #pragma once.  */
-  bool once_only;
+  bool once_only : 1;
 
   /* If read() failed before.  */
-  bool dont_read;
+  bool dont_read : 1;
 
   /* If this file is the main file.  */
-  bool main_file;
+  bool main_file : 1;
 
   /* If BUFFER above contains the true contents of the file.  */
-  bool buffer_valid;
+  bool buffer_valid : 1;
 
   /* If this file is implicitly preincluded.  */
-  bool implicit_preinclude;
+  bool implicit_preinclude : 1;
 };
 
 /* A singly-linked list for all searches for a given file name, with
index 45167a9500eba086dfffe5cdb963208f6e7caeab..a86b58785e9d4c490933dee6d192b13203fec038 100644 (file)
@@ -113,7 +113,17 @@ extern unsigned char *_cpp_unaligned_alloc (cpp_reader *, size_t);
 #define BUFF_LIMIT(BUFF) ((BUFF)->limit)
 
 /* #include types.  */
-enum include_type {IT_INCLUDE, IT_INCLUDE_NEXT, IT_IMPORT, IT_CMDLINE, IT_DEFAULT};
+enum include_type
+  {
+   /* Directive-based including mechanisms.  */
+   IT_INCLUDE,  /* #include */
+   IT_INCLUDE_NEXT,  /* #include_next */
+   IT_IMPORT,   /* #import  */
+
+   /* Non-directive including mechanisms.  */
+   IT_CMDLINE,  /* -include */
+   IT_DEFAULT,  /* forced header  */
+  };
 
 union utoken
 {
@@ -327,23 +337,23 @@ struct cpp_buffer
   struct if_stack *if_stack;
 
   /* True if we need to get the next clean line.  */
-  bool need_line;
+  bool need_line : 1;
 
   /* True if we have already warned about C++ comments in this file.
      The warning happens only for C89 extended mode with -pedantic on,
      or for -Wtraditional, and only once per file (otherwise it would
      be far too noisy).  */
-  unsigned int warned_cplusplus_comments : 1;
+  bool warned_cplusplus_comments : 1;
 
   /* True if we don't process trigraphs and escaped newlines.  True
      for preprocessed input, command line directives, and _Pragma
      buffers.  */
-  unsigned int from_stage3 : 1;
+  bool from_stage3 : 1;
 
   /* At EOF, a buffer is automatically popped.  If RETURN_AT_EOF is
      true, a CPP_EOF token is then returned.  Otherwise, the next
      token from the enclosing buffer is returned.  */
-  unsigned int return_at_eof : 1;
+  bool return_at_eof : 1;
 
   /* One for a system header, two for a C system header file that therefore
      needs to be extern "C" protected in C++, and zero otherwise.  */
@@ -419,13 +429,13 @@ struct cpp_reader
 
   /* This is the node representing the macro being expanded at
      top-level.  The value of this data member is valid iff
-     in_macro_expansion_p() returns TRUE.  */
+     cpp_in_macro_expansion_p() returns TRUE.  */
   cpp_hashnode *top_most_macro_node;
 
   /* Nonzero if we are about to expand a macro.  Note that if we are
      really expanding a macro, the function macro_of_context returns
      the macro being expanded and this flag is set to false.  Client
-     code should use the function in_macro_expansion_p to know if we
+     code should use the function cpp_in_macro_expansion_p to know if we
      are either about to expand a macro, or are actually expanding
      one.  */
   bool about_to_expand_macro_p;
@@ -711,7 +721,7 @@ extern const char *cpp_named_operator2name (enum cpp_ttype type);
 
 /* In directives.c */
 extern int _cpp_test_assertion (cpp_reader *, unsigned int *);
-extern int _cpp_handle_directive (cpp_reader *, int);
+extern int _cpp_handle_directive (cpp_reader *, bool);
 extern void _cpp_define_builtin (cpp_reader *, const char *);
 extern char ** _cpp_save_pragma_names (cpp_reader *);
 extern void _cpp_restore_pragma_names (cpp_reader *, char **);