OSDN Git Service

* c-decl.c (grokdeclarator): Make error for duplicate type
[pf3gnuchains/gcc-fork.git] / gcc / cpphash.h
index 98dfb49..16e8dfe 100644 (file)
@@ -98,8 +98,15 @@ struct cpp_macro
 
   /* 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
@@ -134,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.  */
@@ -159,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
@@ -246,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
 {
@@ -353,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.  */
@@ -370,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.
@@ -409,6 +431,9 @@ 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;
 
@@ -455,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)
@@ -475,7 +499,10 @@ extern bool _cpp_save_parameter            PARAMS ((cpp_reader *, cpp_macro *,
 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 *));
@@ -528,10 +555,11 @@ extern bool _cpp_read_logical_line_trad PARAMS ((cpp_reader *));
 extern void _cpp_overlay_buffer PARAMS ((cpp_reader *pfile, const uchar *,
                                         size_t));
 extern void _cpp_remove_overlay PARAMS ((cpp_reader *));
-extern void _cpp_set_trad_context 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