OSDN Git Service

* class.c (base_derived_from): Make sure return value is a bool.
[pf3gnuchains/gcc-fork.git] / gcc / cpphash.h
index 9a4915d..16e8dfe 100644 (file)
@@ -69,20 +69,44 @@ struct dummy
    Variadic macros cannot occur with traditional cpp.  */
 struct cpp_macro
 {
-  cpp_hashnode **params;       /* Parameters, if any.  */
+  /* Parameters, if any.  */
+  cpp_hashnode **params;
+
+  /* Replacement tokens (ISO) or replacement text (traditional).  See
+     comment at top of cpptrad.c for how traditional function-like
+     macros are encoded.  */
   union
   {
-    cpp_token *tokens;         /* Tokens of replacement list (ISO).  */
-    const uchar *text;         /* Expansion text (traditional).  */
+    cpp_token *tokens;
+    const uchar *text;
   } exp;
-  unsigned int line;           /* Starting line number.  */
-  unsigned int count;          /* Number of tokens / bytes in expansion.  */
-  unsigned short paramc;       /* Number of parameters.  */
-  unsigned int fun_like : 1;   /* If a function-like macro.  */
-  unsigned int variadic : 1;   /* If a variadic macro.  */
-  unsigned int syshdr   : 1;   /* If macro defined in system header.  */
+
+  /* Definition line number.  */
+  unsigned int line;
+
+  /* Number of tokens in expansion, or bytes for traditional macros.  */
+  unsigned int count;
+
+  /* Number of parameters.  */
+  unsigned short paramc;
+
+  /* If a function-like macro.  */
+  unsigned int fun_like : 1;
+
+  /* If a variadic macro.  */
+  unsigned int variadic : 1;
+
+  /* If macro defined in system header.  */
+  unsigned int syshdr   : 1;
+
+  /* Nonzero if it has been expanded or had its existence tested.  */
+  unsigned int used     : 1;
 };
 
+#define _cpp_mark_macro_used(NODE) do {                                        \
+  if ((NODE)->type == NT_MACRO && !((NODE)->flags & NODE_BUILTIN))     \
+    (NODE)->value.macro->used = 1; } while (0)
+
 /* A generic memory buffer, and operations on it.  */
 typedef struct _cpp_buff _cpp_buff;
 struct _cpp_buff
@@ -117,7 +141,7 @@ struct search_path
      of an earlier directory on the search path.  */
   ino_t ino;
   dev_t dev;
-  /* Non-zero if it is a system include directory.  */
+  /* Nonzero if it is a system include directory.  */
   int sysp;
   /* Mapping of file names for this directory.  Only used on MS-DOS
      and related platforms.  */
@@ -142,10 +166,10 @@ struct tokenrun
 };
 
 /* Accessor macros for struct cpp_context.  */
-#define FIRST(c) (c->u.iso.first)
-#define LAST(c) (c->u.iso.last)
-#define CUR(c) (c->u.trad.cur)
-#define RLIMIT(c) (c->u.trad.rlimit)
+#define FIRST(c) ((c)->u.iso.first)
+#define LAST(c) ((c)->u.iso.last)
+#define CUR(c) ((c)->u.trad.cur)
+#define RLIMIT(c) ((c)->u.trad.rlimit)
 
 typedef struct cpp_context cpp_context;
 struct cpp_context
@@ -194,6 +218,9 @@ struct lexer_state
   /* Nonzero if in a directive that takes angle-bracketed headers.  */
   unsigned char angled_headers;
 
+  /* Nonzero if in a #if or #elif directive.  */
+  unsigned char in_expression;
+
   /* Nonzero to save comments.  Turned off if discard_comments, and in
      all directives apart from #define.  */
   unsigned char save_comments;
@@ -226,6 +253,18 @@ struct spec_nodes
   cpp_hashnode *n__VA_ARGS__;          /* C99 vararg macros */
 };
 
+/* Encapsulates state used to convert a stream of tokens into a text
+   file.  */
+struct printer
+{
+  FILE *outf;                  /* Stream to write to.  */
+  const struct line_map *map;  /* Logical to physical line mappings.  */
+  const cpp_token *prev;       /* Previous token.  */
+  const cpp_token *source;     /* Source token for spacing.  */
+  unsigned int line;           /* Line currently being written.  */
+  unsigned char printed;       /* Nonzero if something output at line.  */
+};
+
 /* Represents the contents of a file cpplib has read in.  */
 struct cpp_buffer
 {
@@ -281,7 +320,7 @@ struct cpp_buffer
   struct search_path dir;
 
   /* Used for buffer overlays by cpptrad.c.  */
-  const uchar *saved_cur, *saved_rlimit, *saved_line_base;
+  const uchar *saved_cur, *saved_rlimit;
 };
 
 /* A cpp_reader encapsulates the "state" of a pre-processor run.
@@ -292,6 +331,9 @@ struct cpp_reader
   /* Top of buffer stack.  */
   cpp_buffer *buffer;
 
+  /* Overlaid buffer (can be different after processing #include).  */
+  cpp_buffer *overlaid_buffer;
+
   /* Lexer state.  */
   struct lexer_state state;
 
@@ -330,7 +372,7 @@ struct cpp_reader
   tokenrun base_run, *cur_run;
   unsigned int lookaheads;
 
-  /* Non-zero prevents the lexer from re-using the token runs.  */
+  /* Nonzero prevents the lexer from re-using the token runs.  */
   unsigned int keep_tokens;
 
   /* Error counter for exit code.  */
@@ -347,15 +389,18 @@ struct cpp_reader
      for include files.  (Altered as we get more of them.)  */
   unsigned int max_include_len;
 
-  /* Date and time tokens.  Calculated together if either is requested.  */
-  cpp_token date;
-  cpp_token time;
+  /* Macros on or after this line are warned about if unused.  */
+  unsigned int first_unused_line;
+
+  /* Date and time text.  Calculated together if either is requested.  */
+  const uchar *date;
+  const uchar *time;
 
   /* EOF token, and a token forcing paste avoidance.  */
   cpp_token avoid_paste;
   cpp_token eof;
 
-  /* Opaque handle to the dependencies of mkdeps.c.  Used by -M etc.  */
+  /* Opaque handle to the dependencies of mkdeps.c.  */
   struct deps *deps;
 
   /* Obstack holding all macro hash nodes.  This never shrinks.
@@ -386,13 +431,24 @@ struct cpp_reader
      preprocessor.  */
   struct spec_nodes spec_nodes;
 
+  /* Used when doing preprocessed output.  */
+  struct printer print;
+
   /* Whether cpplib owns the hashtable.  */
   unsigned char our_hashtable;
 
-  /* Traditional preprocessing output buffer.  */
-  uchar *trad_out_base, *trad_out_limit;
-  uchar *trad_out_cur;
-  unsigned int trad_line;
+  /* Traditional preprocessing output buffer (a logical line).  */
+  struct
+  {
+    uchar *base;
+    uchar *limit;
+    uchar *cur;
+    unsigned int first_line;
+  } out;
+
+  /* Used to save the original line number during traditional
+     preprocessing.  */
+  unsigned int saved_line;
 };
 
 /* Character classes.  Based on the more primitive macros in safe-ctype.h.
@@ -424,7 +480,6 @@ extern unsigned char _cpp_trigraph_map[UCHAR_MAX + 1];
 
 /* Macros.  */
 
-#define CPP_PRINT_DEPS(PFILE) CPP_OPTION (PFILE, print_deps)
 #define CPP_IN_SYSTEM_HEADER(PFILE) ((PFILE)->map && (PFILE)->map->sysp)
 #define CPP_PEDANTIC(PF) CPP_OPTION (PF, pedantic)
 #define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, warn_traditional)
@@ -438,10 +493,16 @@ extern void _cpp_free_definition  PARAMS ((cpp_hashnode *));
 extern bool _cpp_create_definition     PARAMS ((cpp_reader *, cpp_hashnode *));
 extern void _cpp_pop_context           PARAMS ((cpp_reader *));
 extern void _cpp_push_text_context     PARAMS ((cpp_reader *, cpp_hashnode *,
-                                                const uchar *, const uchar*));
+                                                const uchar *, size_t));
 extern bool _cpp_save_parameter                PARAMS ((cpp_reader *, cpp_macro *,
                                                 cpp_hashnode *));
-
+extern bool _cpp_arguments_ok          PARAMS ((cpp_reader *, cpp_macro *,
+                                                const cpp_hashnode *,
+                                                unsigned int));
+extern const uchar *_cpp_builtin_macro_text PARAMS ((cpp_reader *,
+                                                    cpp_hashnode *));
+int _cpp_warn_if_unused_macro          PARAMS ((cpp_reader *, cpp_hashnode *,
+                                                void *));
 /* In cpphash.c */
 extern void _cpp_init_hashtable                PARAMS ((cpp_reader *, hash_table *));
 extern void _cpp_destroy_hashtable     PARAMS ((cpp_reader *));
@@ -493,9 +554,12 @@ extern void _cpp_pop_buffer PARAMS ((cpp_reader *));
 extern bool _cpp_read_logical_line_trad PARAMS ((cpp_reader *));
 extern void _cpp_overlay_buffer PARAMS ((cpp_reader *pfile, const uchar *,
                                         size_t));
-extern cpp_hashnode *_cpp_lex_identifier_trad PARAMS ((cpp_reader *));
-extern void _cpp_set_trad_context PARAMS ((cpp_reader *));
+extern void _cpp_remove_overlay PARAMS ((cpp_reader *));
 extern bool _cpp_create_trad_definition PARAMS ((cpp_reader *, cpp_macro *));
+extern bool _cpp_expansions_different_trad PARAMS ((const cpp_macro *,
+                                                   const cpp_macro *));
+extern uchar *_cpp_copy_replacement_text PARAMS ((const cpp_macro *, uchar *));
+extern size_t _cpp_replacement_text_len PARAMS ((const cpp_macro *));
 
 /* Utility routines and macros.  */
 #define DSC(str) (const uchar *)str, sizeof str - 1