aboutsummaryrefslogtreecommitdiff
path: root/libcpp/include
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2018-08-20 12:39:36 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2018-08-20 12:39:36 +0000
commit3fb558b154f795983ae6a9dd6478e18a2c846584 (patch)
tree2c06bad74d6dafddb11979c263020425a716902c /libcpp/include
parentb655b8fc7eb4af02231fa0105dddd90a8cfceea1 (diff)
downloadgcc-3fb558b154f795983ae6a9dd6478e18a2c846584.zip
gcc-3fb558b154f795983ae6a9dd6478e18a2c846584.tar.gz
gcc-3fb558b154f795983ae6a9dd6478e18a2c846584.tar.bz2
[PATCH] #assert becomes macro-like
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01140.html libcpp/ * include/cpp-id-data.h (struct answer): Delete. * include/cpplib.h (struct answer): Don't forward-declare. (enum cpp_macro_kind): Add cmk_assert. (struct cpp_macro): Union parms and next assert chain. (union _cpp_hashnode_value): 'answer' field is cpp_macro. * directives.c (parse_answer): Convert to use cpp_macro. Return true on success. (parse_assertion, find_answer, _cpp_test_assertion, cpp_do_assert) (cpp_do_unassert): Convert to use cpp_macro. * macro.c (warn_of_redefinition, _cpp_new_macro) (check_trad_stringification, cpp_macro_definition): Adjust macro parm access. * traditional.c (_cpp_replacement_text_len) (_cpp_copy_replacement_text, _cpp_create_trad_definition): Likewise. gcc/c-family/ * c-ada-spec.c (macro_length, dump_ada_macros): Adjust macro parm access. From-SVN: r263658
Diffstat (limited to 'libcpp/include')
-rw-r--r--libcpp/include/cpp-id-data.h7
-rw-r--r--libcpp/include/cpplib.h29
2 files changed, 18 insertions, 18 deletions
diff --git a/libcpp/include/cpp-id-data.h b/libcpp/include/cpp-id-data.h
index fb073fa..909f828 100644
--- a/libcpp/include/cpp-id-data.h
+++ b/libcpp/include/cpp-id-data.h
@@ -17,10 +17,3 @@ along with this program; see the file COPYING3. If not see
#include "cpplib.h"
-/* Chained list of answers to an assertion. */
-struct GTY(()) answer {
- struct answer *next;
- unsigned int count;
- cpp_token GTY ((length ("%h.count"))) first[1];
-};
-
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index e0be2dc..d446fb1 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -36,7 +36,6 @@ typedef struct cpp_macro cpp_macro;
typedef struct cpp_callbacks cpp_callbacks;
typedef struct cpp_dir cpp_dir;
-struct answer;
struct _cpp_file;
/* The first three groups, apart from '=', can appear in preprocessor
@@ -674,25 +673,33 @@ struct cpp_dir
/* The kind of the cpp_macro. */
enum cpp_macro_kind {
cmk_macro, /* An ISO macro (token expansion). */
+ cmk_assert, /* An assertion. */
cmk_traditional, /* A traditional macro (text expansion). */
};
/* Each macro definition is recorded in a cpp_macro structure.
Variadic macros cannot occur with traditional cpp. */
struct GTY(()) cpp_macro {
- /* Parameters, if any. If parameter names use extended identifiers,
- the original spelling of those identifiers, not the canonical
- UTF-8 spelling, goes here. */
- cpp_hashnode ** GTY ((nested_ptr (union tree_node,
- "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
- "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"),
- length ("%h.paramc")))
- params;
+ union cpp_parm_u
+ {
+ /* Parameters, if any. If parameter names use extended identifiers,
+ the original spelling of those identifiers, not the canonical
+ UTF-8 spelling, goes here. */
+ cpp_hashnode ** GTY ((tag ("false"),
+ nested_ptr (union tree_node,
+ "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
+ "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"),
+ length ("%1.paramc"))) params;
+
+ /* If this is an assertion, the next one in the chain. */
+ cpp_macro *GTY ((tag ("true"))) next;
+ } GTY ((desc ("%1.kind == cmk_assert"))) parm;
/* Definition line number. */
source_location line;
- /* Number of tokens in expansion, or bytes for traditional macros. */
+ /* Number of tokens in body, or bytes for traditional macros. */
+ /* Do we really need 2^32-1 range here? */
unsigned int count;
/* Number of parameters. */
@@ -814,7 +821,7 @@ union GTY(()) _cpp_hashnode_value {
/* If a macro. */
cpp_macro * GTY((tag ("NTV_MACRO"))) macro;
/* Answers to an assertion. */
- struct answer * GTY ((tag ("NTV_ANSWER"))) answers;
+ cpp_macro * GTY ((tag ("NTV_ANSWER"))) answers;
/* Code for a builtin macro. */
enum cpp_builtin_type GTY ((tag ("NTV_BUILTIN"))) builtin;
/* Macro argument index. */