@@ -71,6 +71,23 @@ struct GTY (()) cp_token {
"|| (%1.type == CPP_DECLTYPE)"))) u;
};
+/* The C++ frontend lexes everything first, and keeps the tokens
+ in memory, so there are possibly millions of tokens in memory.
+
+ Use a STATIC_ASSERT to ensure that we don't accidentally grow
+ the structure.
+
+ To avoid introducing too many assumptions on the host data layout,
+ only enable the assertion when compiling with GCC for a
+ known-good host. */
+#if defined (__GNUC__) && defined (__x86_64__)
+STATIC_ASSERT (sizeof (cp_token) ==
+ (2 // "type" and "keyword"
+ + 1 // "flags"
+ + 1 // bitfields
+ + 4 // location_t
+ + sizeof (void *))); // union
+#endif /* #if defined (__GNUC__) && defined (__x86_64__) */
/* We use a stack of token pointer for saving token sets. */
typedef struct cp_token *cp_token_position;