]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add cmk_assert structures
authorNathan Sidwell <nathan@acm.org>
Wed, 11 Jul 2018 16:14:14 +0000 (16:14 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 11 Jul 2018 16:14:14 +0000 (16:14 +0000)
Add cmk_assert structures
libcpp/
* include/cpp-id-data.h (enum cpp_macro_kind): Add cmk_assert.
(struct cpp_macro): Place parms in union.
* macro.c (warn_of_redefinition): Adjust param field access.
(create_iso_definiton, _cpp_create_definition): Likewise.
(check_trad_stringification, cpp_macro_definition): Likewise.
* traditional.c (_cpp_replacement_text_len): Likewise.
(_cpp_copy_replacement_text, _cpp_create_trad_definition): Likewise.
gcc/c-family/
* c-ada-spec.c (macro_length, dump_ada_macros): Adjust param field
access.

From-SVN: r262558

ChangeLog.name-lookup
gcc/c-family/c-ada-spec.c
libcpp/include/cpp-id-data.h
libcpp/macro.c
libcpp/traditional.c

index 06e100379d21a2d80401828abf588c029547b587..daf4fb7cf33b0082057fda383bf93677cd92656a 100644 (file)
@@ -1,5 +1,18 @@
 2018-07-11  Nathan Sidwell  <nathan@acm.org>
 
+       Add cmk_assert structures
+       libcpp/
+       * include/cpp-id-data.h (enum cpp_macro_kind): Add cmk_assert.
+       (struct cpp_macro): Place parms in union.
+       * macro.c (warn_of_redefinition): Adjust param field access.
+       (create_iso_definiton, _cpp_create_definition): Likewise.
+       (check_trad_stringification, cpp_macro_definition): Likewise.
+       * traditional.c (_cpp_replacement_text_len): Likewise.
+       (_cpp_copy_replacement_text, _cpp_create_trad_definition): Likewise.
+       gcc/c-family/
+       * c-ada-spec.c (macro_length, dump_ada_macros): Adjust param field
+       access.
+
        Add cpp_macro_kind
        libcpp/
        * include/cpp-id-data.h (enum cpp_macro_kind): New.
index 99b6f0581431a2535573abadc0a1492b72e113c0..f1b02d8f2fc1a0a5918b8991abb2e0e57b82166e 100644 (file)
@@ -70,7 +70,7 @@ macro_length (const cpp_macro *macro, int *supported, int *buffer_len,
       (*param_len)++;
       for (i = 0; i < macro->paramc; i++)
        {
-         cpp_hashnode *param = macro->params[i];
+         cpp_hashnode *param = macro->parm.params[i];
 
          *param_len += NODE_LEN (param);
 
@@ -102,7 +102,7 @@ macro_length (const cpp_macro *macro, int *supported, int *buffer_len,
 
       if (token->type == CPP_MACRO_ARG)
        *buffer_len +=
-         NODE_LEN (macro->params[token->val.macro_arg.arg_no - 1]);
+         NODE_LEN (macro->parm.params[token->val.macro_arg.arg_no - 1]);
       else
        /* Include enough extra space to handle e.g. special characters.  */
        *buffer_len += (cpp_token_len (token) + 1) * 8;
@@ -253,7 +253,7 @@ dump_ada_macros (pretty_printer *pp, const char* file)
              *buf_param++ = '(';
              for (i = 0; i < macro->paramc; i++)
                {
-                 cpp_hashnode *param = macro->params[i];
+                 cpp_hashnode *param = macro->parm.params[i];
 
                  memcpy (buf_param, NODE_NAME (param), NODE_LEN (param));
                  buf_param += NODE_LEN (param);
@@ -292,7 +292,7 @@ dump_ada_macros (pretty_printer *pp, const char* file)
                  case CPP_MACRO_ARG:
                    {
                      cpp_hashnode *param =
-                       macro->params[token->val.macro_arg.arg_no - 1];
+                       macro->parm.params[token->val.macro_arg.arg_no - 1];
                      memcpy (buffer, NODE_NAME (param), NODE_LEN (param));
                      buffer += NODE_LEN (param);
                    }
index f4596b69dc41cefd6e5ac2f22f2fc70bf1c5dc50..8117a8893de5259d0365699d4546873945691d56 100644 (file)
@@ -33,24 +33,32 @@ struct GTY(()) answer {
 /* 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,
+  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 ("%h.paramc"))) params;
+                         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;
 
   union cpp_exp_u
   {
     /* Replacement tokens (ISO), or assertion body value.  */
-    cpp_token * GTY ((tag ("false"), length ("%0.count"))) tokens;
+    cpp_token * GTY ((tag ("false"), length ("%1.count"))) tokens;
 
     /* Replacement text (traditional).  See comment at top of
        cpptrad.c for how traditional function-like macros are
index d8ea69230c1d8afd78a8e051124416cf567d5630..0d798fdc4ca294a75ae6b91260895dc51b699152 100644 (file)
@@ -3032,7 +3032,7 @@ warn_of_redefinition (cpp_reader *pfile, cpp_hashnode *node,
 
   /* Check parameter spellings.  */
   for (i = 0; i < macro1->paramc; i++)
-    if (macro1->params[i] != macro2->params[i])
+    if (macro1->parm.params[i] != macro2->parm.params[i])
       return true;
 
   /* Check the replacement text or tokens.  */
@@ -3257,7 +3257,7 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro)
   if (ctoken->type == CPP_OPEN_PAREN && !(ctoken->flags & PREV_WHITE))
     {
       bool ok = parse_params (pfile, macro);
-      macro->params = (cpp_hashnode **) BUFF_FRONT (pfile->a_buff);
+      macro->parm.params = (cpp_hashnode **) BUFF_FRONT (pfile->a_buff);
       if (!ok)
        return false;
 
@@ -3267,12 +3267,13 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro)
          cpp_hashnode **params =
             (cpp_hashnode **) pfile->hash_table->alloc_subobject
             (sizeof (cpp_hashnode *) * macro->paramc);
-         memcpy (params, macro->params,
+         memcpy (params, macro->parm.params,
                  sizeof (cpp_hashnode *) * macro->paramc);
-         macro->params = params;
+         macro->parm.params = params;
        }
       else
-       BUFF_FRONT (pfile->a_buff) = (uchar *) &macro->params[macro->paramc];
+       BUFF_FRONT (pfile->a_buff)
+         = (uchar *) &macro->parm.params[macro->paramc];
       macro->fun_like = 1;
     }
   else if (ctoken->type != CPP_EOF && !(ctoken->flags & PREV_WHITE))
@@ -3464,7 +3465,7 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node)
   else
     macro = (cpp_macro *) _cpp_aligned_alloc (pfile, sizeof (cpp_macro));
   macro->line = pfile->directive_line;
-  macro->params = 0;
+  macro->parm.params = 0;
   macro->paramc = 0;
   macro->variadic = 0;
   macro->used = !CPP_OPTION (pfile, warn_unused_macros);
@@ -3576,7 +3577,7 @@ check_trad_stringification (cpp_reader *pfile, const cpp_macro *macro,
         identifier inside the string matches one of them.  */
       for (i = 0; i < macro->paramc; i++)
        {
-         const cpp_hashnode *node = macro->params[i];
+         const cpp_hashnode *node = macro->parm.params[i];
 
          if (NODE_LEN (node) == len
              && !memcmp (p, NODE_NAME (node), len))
@@ -3630,7 +3631,7 @@ cpp_macro_definition (cpp_reader *pfile, cpp_hashnode *node)
       len += 4;                /* "()" plus possible final ".." of named
                           varargs (we have + 1 below).  */
       for (i = 0; i < macro->paramc; i++)
-       len += NODE_LEN (macro->params[i]) + 1; /* "," */
+       len += NODE_LEN (macro->parm.params[i]) + 1; /* "," */
     }
 
   /* This should match below where we fill in the buffer.  */
@@ -3674,7 +3675,7 @@ cpp_macro_definition (cpp_reader *pfile, cpp_hashnode *node)
       *buffer++ = '(';
       for (i = 0; i < macro->paramc; i++)
        {
-         cpp_hashnode *param = macro->params[i];
+         cpp_hashnode *param = macro->parm.params[i];
 
          if (param != pfile->spec_nodes.n__VA_ARGS__)
            {
index 3cb967371437d8a662069c52411b536b2fbf6844..795fb277ac479fe8bdac7cb263c30d34d4e7c180 100644 (file)
@@ -919,7 +919,7 @@ _cpp_replacement_text_len (const cpp_macro *macro)
          len += b->text_len;
          if (b->arg_index == 0)
            break;
-         len += NODE_LEN (macro->params[b->arg_index - 1]);
+         len += NODE_LEN (macro->parm.params[b->arg_index - 1]);
          exp += BLOCK_LEN (b->text_len);
        }
     }
@@ -948,7 +948,7 @@ _cpp_copy_replacement_text (const cpp_macro *macro, uchar *dest)
          dest += b->text_len;
          if (b->arg_index == 0)
            break;
-         param = macro->params[b->arg_index - 1];
+         param = macro->parm.params[b->arg_index - 1];
          memcpy (dest, NODE_NAME (param), NODE_LEN (param));
          dest += NODE_LEN (param);
          exp += BLOCK_LEN (b->text_len);
@@ -1195,7 +1195,7 @@ _cpp_create_trad_definition (cpp_reader *pfile, cpp_macro *macro)
       bool ok = scan_parameters (pfile, macro);
 
       /* Remember the params so we can clear NODE_MACRO_ARG flags.  */
-      macro->params = (cpp_hashnode **) BUFF_FRONT (pfile->a_buff);
+      macro->parm.params = (cpp_hashnode **) BUFF_FRONT (pfile->a_buff);
 
       /* Setting macro to NULL indicates an error occurred, and
         prevents unnecessary work in _cpp_scan_out_logical_line.  */
@@ -1203,7 +1203,8 @@ _cpp_create_trad_definition (cpp_reader *pfile, cpp_macro *macro)
        macro = NULL;
       else
        {
-         BUFF_FRONT (pfile->a_buff) = (uchar *) &macro->params[macro->paramc];
+         BUFF_FRONT (pfile->a_buff)
+           = (uchar *) &macro->parm.params[macro->paramc];
          macro->fun_like = 1;
        }
     }