aboutsummaryrefslogtreecommitdiff
path: root/libcpp/directives.c
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>2004-06-05 20:58:06 +0000
committerZack Weinberg <zack@gcc.gnu.org>2004-06-05 20:58:06 +0000
commitc6e8380069ff630939beec0b5872a37f5b710189 (patch)
treef9776b653c83d7c1faa17b330fe162333d109cc2 /libcpp/directives.c
parentdbeff3e56d566719bb3f0c1ba29362d61fe3ff85 (diff)
downloadgcc-c6e8380069ff630939beec0b5872a37f5b710189.zip
gcc-c6e8380069ff630939beec0b5872a37f5b710189.tar.gz
gcc-c6e8380069ff630939beec0b5872a37f5b710189.tar.bz2
Makefile.am: Add makedepend.
libcpp: * Makefile.am: Add makedepend. * Makefile.in, aclocal.m4: Regenerate. * charset.c: Insert a space to avoid a warning. * directives.c: Include mkdeps.h. (_cpp_handle_directive): Reenable macro expander if appropriate. (undefine_macros): Inline body of _cpp_free_definition for speed. Do not call undef callback or _cpp_warn_if_unused_macro. (cpp_get_deps): New interface. * files.c (search_cache): Add pfile argument. Check for file that would be found by "" or <> search here... (_cpp_find_file): ...not here. Correct recorded start_dir of files found by directory-of-current-file search that would be found by "" or <> search. * init.c (cpp_add_dependency_target): Delete. * internal.h (struct lexer_state): Add discarding_output flag. * lex.c (lex_identifier): Compute hash function while scanning. * macro.c (cpp_scan_nooutput): Disable macro expansion outside directives. * makedepend.c: New file. * mkdeps.c (struct deps): Add vpath vector. (apply_vpath, deps_add_vpath): New function. (deps_free): Free vpath vector. (deps_add_dep, deps_add_target): Use apply_vpath. * symtab.c (calc_hash): Use HT_HASHSTEP and HT_FINISH. (ht_lookup_with_hash): New function. * cpplib.h, mkdeps.h: Update prototypes. * symtab.h: Update prototypes. (HT_HASHSTEP, HT_FINISH): New macros. gcc: * Makefile.in (MKDEPS_H): New shorthand. (c-opts.o): Update dependencies. * c-opts.c: Include mkdeps.h. (handle_deferred_opts): Use cpp_get_deps and deps_add_target, not cpp_add_dependency_target. From-SVN: r82654
Diffstat (limited to 'libcpp/directives.c')
-rw-r--r--libcpp/directives.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/libcpp/directives.c b/libcpp/directives.c
index f9ff2ce..5a6a342 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -23,6 +23,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "system.h"
#include "cpplib.h"
#include "internal.h"
+#include "mkdeps.h"
#include "obstack.h"
/* Chained list of answers to an assertion. */
@@ -336,8 +337,12 @@ _cpp_handle_directive (cpp_reader *pfile, int indented)
const directive *dir = 0;
const cpp_token *dname;
bool was_parsing_args = pfile->state.parsing_args;
+ bool was_discarding_output = pfile->state.discarding_output;
int skip = 1;
+ if (was_discarding_output)
+ pfile->state.prevent_expansion = 0;
+
if (was_parsing_args)
{
if (CPP_OPTION (pfile, pedantic))
@@ -432,6 +437,8 @@ _cpp_handle_directive (cpp_reader *pfile, int indented)
pfile->state.parsing_args = 2;
pfile->state.prevent_expansion = 1;
}
+ if (was_discarding_output)
+ pfile->state.prevent_expansion = 1;
return skip;
}
@@ -549,30 +556,13 @@ do_undef (cpp_reader *pfile)
/* Undefine a single macro/assertion/whatever. */
static int
-undefine_macros (cpp_reader *pfile, cpp_hashnode *h,
+undefine_macros (cpp_reader *pfile ATTRIBUTE_UNUSED, cpp_hashnode *h,
void *data_p ATTRIBUTE_UNUSED)
{
- switch (h->type)
- {
- case NT_VOID:
- break;
-
- case NT_MACRO:
- if (pfile->cb.undef)
- (*pfile->cb.undef) (pfile, pfile->directive_line, h);
-
- if (CPP_OPTION (pfile, warn_unused_macros))
- _cpp_warn_if_unused_macro (pfile, h, NULL);
-
- /* And fall through.... */
- case NT_ASSERTION:
- _cpp_free_definition (h);
- break;
-
- default:
- abort ();
- }
- h->flags &= ~NODE_POISONED;
+ /* Body of _cpp_free_definition inlined here for speed.
+ Macros and assertions no longer have anything to free. */
+ h->type = NT_VOID;
+ h->flags &= ~(NODE_POISONED|NODE_BUILTIN|NODE_DISABLED);
return 1;
}
@@ -1913,6 +1903,15 @@ cpp_set_callbacks (cpp_reader *pfile, cpp_callbacks *cb)
pfile->cb = *cb;
}
+/* The dependencies structure. (Creates one if it hasn't already been.) */
+struct deps *
+cpp_get_deps (cpp_reader *pfile)
+{
+ if (!pfile->deps)
+ pfile->deps = deps_init ();
+ return pfile->deps;
+}
+
/* Push a new buffer on the buffer stack. Returns the new buffer; it
doesn't fail. It does not generate a file change call back; that
is the responsibility of the caller. */