aboutsummaryrefslogtreecommitdiff
path: root/contrib/gcclibs
diff options
context:
space:
mode:
authorPedro F. Giffuni <pfg@FreeBSD.org>2016-08-30 19:39:33 +0000
committerPedro F. Giffuni <pfg@FreeBSD.org>2016-08-30 19:39:33 +0000
commit66a5fa5d99e242b91d2151ecf06776d45112eaa0 (patch)
tree474f51fb29836cab20a5f908fe2e91c958d6432f /contrib/gcclibs
parent533f3e1026c2e2ab4ddc136aafeecae024dd8e49 (diff)
Notes
Diffstat (limited to 'contrib/gcclibs')
-rw-r--r--contrib/gcclibs/libcpp/ChangeLog.gcc4311
-rw-r--r--contrib/gcclibs/libcpp/internal.h3
-rw-r--r--contrib/gcclibs/libcpp/macro.c2
-rw-r--r--contrib/gcclibs/libcpp/pch.c41
4 files changed, 55 insertions, 2 deletions
diff --git a/contrib/gcclibs/libcpp/ChangeLog.gcc43 b/contrib/gcclibs/libcpp/ChangeLog.gcc43
index da70d1c30056..be5174336323 100644
--- a/contrib/gcclibs/libcpp/ChangeLog.gcc43
+++ b/contrib/gcclibs/libcpp/ChangeLog.gcc43
@@ -12,6 +12,17 @@
PR preprocessor/14331
* lex.c (_cpp_get_fresh_line): Don't warn if no newline at EOF.
+2007-05-24 Ollie Wild <aaw@google.com> (r125041)
+
+ * macro.c (_cpp_builtin_macro_text): Handle BT_COUNTER.
+ * pch.c (cpp_write_pch_deps): Save __COUNTER__ state.
+ (cpp_write_pch_state): Save __COUNTER__ state.
+ (cpp_valid_state): Check valid __COUNTER__ state.
+ (cpp_read_state): Read new __COUNTER__ state.
+ * include/cpplib.h (enum builtin_type): Add BT_COUNTER enumerator.
+ * init.c (builtin_array): Add __COUNTER__/BT_COUNTER.
+ * internal.h (struct cpp_reader): Add counter member.
+
2007-05-21 Ian Lance Taylor <iant@google.com> (r124929)
* internal.h (struct cpp_reader): Add new fields:
diff --git a/contrib/gcclibs/libcpp/internal.h b/contrib/gcclibs/libcpp/internal.h
index d685e283c5cf..d882d8d9b304 100644
--- a/contrib/gcclibs/libcpp/internal.h
+++ b/contrib/gcclibs/libcpp/internal.h
@@ -458,7 +458,8 @@ struct cpp_reader
of precompiled headers. */
struct cpp_savedstate *savedstate;
- unsigned int nextcounter;
+ /* Next value of __COUNTER__ macro. */
+ unsigned int counter;
};
/* Character classes. Based on the more primitive macros in safe-ctype.h.
diff --git a/contrib/gcclibs/libcpp/macro.c b/contrib/gcclibs/libcpp/macro.c
index e9d4681a398a..059f0e3c3ae4 100644
--- a/contrib/gcclibs/libcpp/macro.c
+++ b/contrib/gcclibs/libcpp/macro.c
@@ -268,7 +268,7 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
if (CPP_OPTION (pfile, directives_only) && pfile->state.in_directive)
cpp_error (pfile, CPP_DL_ERROR,
"__COUNTER__ expanded inside directive with -fdirectives-only");
- number = pfile->nextcounter++;
+ number = pfile->counter++;
break;
}
diff --git a/contrib/gcclibs/libcpp/pch.c b/contrib/gcclibs/libcpp/pch.c
index 624befd09d8f..1db2aa70b80b 100644
--- a/contrib/gcclibs/libcpp/pch.c
+++ b/contrib/gcclibs/libcpp/pch.c
@@ -337,6 +337,14 @@ cpp_write_pch_deps (cpp_reader *r, FILE *f)
/* Free the saved state. */
free (ss);
r->savedstate = NULL;
+
+ /* Save the next value of __COUNTER__. */
+ if (fwrite (&r->counter, sizeof (r->counter), 1, f) != 1)
+ {
+ cpp_errno (r, CPP_DL_ERROR, "while writing precompiled header");
+ return -1;
+ }
+
return 0;
}
@@ -361,6 +369,15 @@ cpp_write_pch_state (cpp_reader *r, FILE *f)
return -1;
}
+ /* Save the next __COUNTER__ value. When we include a precompiled header,
+ we need to start at the offset we would have if the header had been
+ included normally. */
+ if (fwrite (&r->counter, sizeof (r->counter), 1, f) != 1)
+ {
+ cpp_errno (r, CPP_DL_ERROR, "while writing precompiled header");
+ return -1;
+ }
+
return 0;
}
@@ -423,6 +440,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
struct ht_node_list nl = { 0, 0, 0 };
unsigned char *first, *last;
unsigned int i;
+ unsigned int counter;
/* Read in the list of identifiers that must be defined
Check that they are defined in the same way. */
@@ -524,7 +542,23 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
}
free(nl.defs);
+ nl.defs = NULL;
free (undeftab);
+ undeftab = NULL;
+
+ /* Read in the next value of __COUNTER__.
+ Check that (a) __COUNTER__ was not used in the pch or (b) __COUNTER__
+ has not been used in this translation unit. */
+ if (read (fd, &counter, sizeof (counter)) != sizeof (counter))
+ goto error;
+ if (counter && r->counter)
+ {
+ if (CPP_OPTION (r, warn_invalid_pch))
+ cpp_error (r, CPP_DL_WARNING_SYSHDR,
+ "%s: not used because `__COUNTER__' is invalid",
+ name);
+ goto fail;
+ }
/* We win! */
return 0;
@@ -631,6 +665,7 @@ cpp_read_state (cpp_reader *r, const char *name, FILE *f,
{
size_t i;
struct lexer_state old_state;
+ unsigned int counter;
/* Restore spec_nodes, which will be full of references to the old
hashtable entries and so will now be invalid. */
@@ -690,6 +725,12 @@ cpp_read_state (cpp_reader *r, const char *name, FILE *f,
if (! _cpp_read_file_entries (r, f))
goto error;
+ if (fread (&counter, sizeof (counter), 1, f) != 1)
+ goto error;
+
+ if (!r->counter)
+ r->counter = counter;
+
return 0;
error: