summaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-27 17:09:38 +0000
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-27 17:09:38 +0000
commit2e82cf2c6076fa6cf9a23ba5b58b9be5f97a10a2 (patch)
tree820f36cafea197aafe4a4a9b0925081fe2507eac /libcpp
parentab0c4d2eb2f6ebde5e397ab479f7a955d62e6106 (diff)
downloadgcc-2e82cf2c6076fa6cf9a23ba5b58b9be5f97a10a2.tar.gz
PR c/61861
* macro.c (builtin_macro): Add location parameter. Set location of builtin macro to the expansion point. (enter_macro_context): Pass location to builtin_macro. * gcc.dg/pr61861.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@213102 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog7
-rw-r--r--libcpp/macro.c11
2 files changed, 14 insertions, 4 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 7a6b8e3a5cc..e550d177c26 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,10 @@
+2014-07-27 Marek Polacek <polacek@redhat.com>
+
+ PR c/61861
+ * macro.c (builtin_macro): Add location parameter. Set
+ location of builtin macro to the expansion point.
+ (enter_macro_context): Pass location to builtin_macro.
+
2014-07-16 Dodji Seketeli <dodji@redhat.com>
Support location tracking for built-in macro tokens
diff --git a/libcpp/macro.c b/libcpp/macro.c
index 3b8fa406935..556628ba7c7 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -84,7 +84,7 @@ struct macro_arg_token_iter
static int enter_macro_context (cpp_reader *, cpp_hashnode *,
const cpp_token *, source_location);
-static int builtin_macro (cpp_reader *, cpp_hashnode *);
+static int builtin_macro (cpp_reader *, cpp_hashnode *, source_location);
static void push_ptoken_context (cpp_reader *, cpp_hashnode *, _cpp_buff *,
const cpp_token **, unsigned int);
static void push_extended_tokens_context (cpp_reader *, cpp_hashnode *,
@@ -399,9 +399,10 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
/* Convert builtin macros like __FILE__ to a token and push it on the
context stack. Also handles _Pragma, for which a new token may not
be created. Returns 1 if it generates a new token context, 0 to
- return the token to the caller. */
+ return the token to the caller. LOC is the location of the expansion
+ point of the macro. */
static int
-builtin_macro (cpp_reader *pfile, cpp_hashnode *node)
+builtin_macro (cpp_reader *pfile, cpp_hashnode *node, source_location loc)
{
const uchar *buf;
size_t len;
@@ -429,6 +430,8 @@ builtin_macro (cpp_reader *pfile, cpp_hashnode *node)
/* Set pfile->cur_token as required by _cpp_lex_direct. */
pfile->cur_token = _cpp_temp_token (pfile);
cpp_token *token = _cpp_lex_direct (pfile);
+ /* We should point to the expansion point of the builtin macro. */
+ token->src_loc = loc;
if (pfile->context->tokens_kind == TOKENS_KIND_EXTENDED)
{
/* We are tracking tokens resulting from macro expansion.
@@ -1212,7 +1215,7 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node,
pfile->about_to_expand_macro_p = false;
/* Handle built-in macros and the _Pragma operator. */
- return builtin_macro (pfile, node);
+ return builtin_macro (pfile, node, location);
}
/* De-allocate the memory used by BUFF which is an array of instances