summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-11-20 08:18:16 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2009-11-20 08:18:16 +0000
commit116f0a5ff416372139ac330ded7f2db9190dfee4 (patch)
treed1a4b34f3473096402637027d37a05d9064c3507 /libcpp
parent7e74cd03929534bffbd67ea492b1d168329ff5ff (diff)
downloadgcc-116f0a5ff416372139ac330ded7f2db9190dfee4.tar.gz
* macro.c (enter_macro_context): Call cb.used callback if defined.
* directives.c (do_idef, do_ifndef): Ditto. * include/cpplib.h (struct cpp_callbacks): Add used callback. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154359 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/directives.c4
-rw-r--r--libcpp/include/cpplib.h3
-rw-r--r--libcpp/macro.c3
4 files changed, 16 insertions, 0 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index c842e80c91d..af05ca31515 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,9 @@
+2009-11-20 Arnaud Charlet <charlet@adacore.com>
+
+ * macro.c (enter_macro_context): Call cb.used callback if defined.
+ * directives.c (do_idef, do_ifndef): Ditto.
+ * include/cpplib.h (struct cpp_callbacks): Add used callback.
+
2009-11-11 Kai Tietz <kai.tietz@onevision.com>
* directives.c (do_pragma_push_macro): New pragma handler.
diff --git a/libcpp/directives.c b/libcpp/directives.c
index aed940e56e1..409d908b4e8 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -1808,6 +1808,8 @@ do_ifdef (cpp_reader *pfile)
pfile->cb.used_undef (pfile, pfile->directive_line, node);
}
}
+ if (pfile->cb.used)
+ pfile->cb.used (pfile, pfile->directive_line, node);
check_eol (pfile, false);
}
}
@@ -1844,6 +1846,8 @@ do_ifndef (cpp_reader *pfile)
pfile->cb.used_undef (pfile, pfile->directive_line, node);
}
}
+ if (pfile->cb.used)
+ pfile->cb.used (pfile, pfile->directive_line, node);
check_eol (pfile, false);
}
}
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index e95f01a412a..6175bbcb092 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -508,6 +508,9 @@ struct cpp_callbacks
/* Called before #define and #undef or other macro definition
changes are processed. */
void (*before_define) (cpp_reader *);
+ /* Called whenever a macro is expanded or tested.
+ Second argument is the location of the start of the current expansion. */
+ void (*used) (cpp_reader *, source_location, cpp_hashnode *);
};
#ifdef VMS
diff --git a/libcpp/macro.c b/libcpp/macro.c
index 1d284cf9f8a..6647db56714 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -885,6 +885,9 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node,
pfile->cb.used_define (pfile, pfile->directive_line, node);
}
+ if (pfile->cb.used)
+ pfile->cb.used (pfile, result->src_loc, node);
+
macro->used = 1;
if (macro->paramc == 0)