OSDN Git Service

* doc/tm.texi (defmac SMALL_REGISTER_CLASSES): Remove.
[pf3gnuchains/gcc-fork.git] / libcpp / macro.c
index 3685397..cbb0b0e 100644 (file)
@@ -83,8 +83,8 @@ _cpp_warn_if_unused_macro (cpp_reader *pfile, cpp_hashnode *node,
 
       if (!macro->used
          && MAIN_FILE_P (linemap_lookup (pfile->line_table, macro->line)))
-       cpp_error_with_line (pfile, CPP_DL_WARNING, macro->line, 0,
-                            "macro \"%s\" is not used", NODE_NAME (node));
+       cpp_warning_with_line (pfile, CPP_W_UNUSED_MACROS, macro->line, 0,
+                              "macro \"%s\" is not used", NODE_NAME (node));
     }
 
   return 1;
@@ -377,9 +377,10 @@ stringify_arg (cpp_reader *pfile, macro_arg *arg)
        }
 
       escape_it = (token->type == CPP_STRING || token->type == CPP_CHAR
-                  || token->type == CPP_WSTRING || token->type == CPP_STRING
+                  || token->type == CPP_WSTRING || token->type == CPP_WCHAR
                   || token->type == CPP_STRING32 || token->type == CPP_CHAR32
-                  || token->type == CPP_STRING16 || token->type == CPP_CHAR16);
+                  || token->type == CPP_STRING16 || token->type == CPP_CHAR16
+                  || token->type == CPP_UTF8STRING);
 
       /* Room for each char being written in octal, initial space and
         final quote and NUL.  */
@@ -859,9 +860,9 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node,
          if (buff == NULL)
            {
              if (CPP_WTRADITIONAL (pfile) && ! node->value.macro->syshdr)
-               cpp_error (pfile, CPP_DL_WARNING,
+               cpp_warning (pfile, CPP_W_TRADITIONAL,
  "function-like macro \"%s\" must be used with arguments in traditional C",
-                          NODE_NAME (node));
+                            NODE_NAME (node));
 
              if (pragma_buff)
                _cpp_release_buff (pfile, pragma_buff);
@@ -884,6 +885,9 @@ enter_macro_context (cpp_reader *pfile, cpp_hashnode *node,
            pfile->cb.used_define (pfile, pfile->directive_line, node);
        }
 
+      if (pfile->cb.used)
+       pfile->cb.used (pfile, result->src_loc, node);
+
       macro->used = 1;
 
       if (macro->paramc == 0)
@@ -946,7 +950,7 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro, macro_arg
 
        /* We have an argument.  If it is not being stringified or
           pasted it is macro-replaced before insertion.  */
-       arg = &args[src->val.arg_no - 1];
+       arg = &args[src->val.macro_arg.arg_no - 1];
 
        if (src->flags & STRINGIFY_ARG)
          {
@@ -982,7 +986,7 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro, macro_arg
        }
 
       paste_flag = 0;
-      arg = &args[src->val.arg_no - 1];
+      arg = &args[src->val.macro_arg.arg_no - 1];
       if (src->flags & STRINGIFY_ARG)
        count = 1, from = &arg->stringified;
       else if (src->flags & PASTE_LEFT)
@@ -994,7 +998,7 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro, macro_arg
            {
              if (dest[-1]->type == CPP_COMMA
                  && macro->variadic
-                 && src->val.arg_no == macro->paramc)
+                 && src->val.macro_arg.arg_no == macro->paramc)
                {
                  /* Swallow a pasted comma if from == NULL, otherwise
                     drop the paste flag.  */
@@ -1035,7 +1039,7 @@ replace_args (cpp_reader *pfile, cpp_hashnode *node, cpp_macro *macro, macro_arg
                     "empty macro arguments are undefined"
                     " in ISO C90 and ISO C++98",
                     NODE_NAME (node),
-                    src->val.arg_no);
+                    src->val.macro_arg.arg_no);
        }
 
       /* Avoid paste on RHS (even case count == 0).  */
@@ -1261,7 +1265,7 @@ cpp_get_token (cpp_reader *pfile)
       if (result->type != CPP_NAME)
        break;
 
-      node = result->val.node;
+      node = result->val.node.node;
 
       if (node->type != NT_MACRO || (result->flags & NO_EXPAND))
        break;
@@ -1553,7 +1557,7 @@ parse_params (cpp_reader *pfile, cpp_macro *macro)
            }
          prev_ident = 1;
 
-         if (_cpp_save_parameter (pfile, macro, token->val.node))
+         if (_cpp_save_parameter (pfile, macro, token->val.node.node))
            return false;
          continue;
 
@@ -1581,13 +1585,14 @@ parse_params (cpp_reader *pfile, cpp_macro *macro)
              if (! CPP_OPTION (pfile, c99)
                  && CPP_OPTION (pfile, pedantic)
                  && CPP_OPTION (pfile, warn_variadic_macros))
-               cpp_error (pfile, CPP_DL_PEDWARN,
-                          "anonymous variadic macros were introduced in C99");
+               cpp_pedwarning
+                  (pfile, CPP_W_VARIADIC_MACROS,
+                  "anonymous variadic macros were introduced in C99");
            }
          else if (CPP_OPTION (pfile, pedantic)
                   && CPP_OPTION (pfile, warn_variadic_macros))
-           cpp_error (pfile, CPP_DL_PEDWARN,
-                      "ISO C does not permit named variadic macros");
+           cpp_pedwarning (pfile, CPP_W_VARIADIC_MACROS,
+                           "ISO C does not permit named variadic macros");
 
          /* We're at the end, and just expect a closing parenthesis.  */
          token = _cpp_lex_token (pfile);
@@ -1626,10 +1631,10 @@ lex_expansion_token (cpp_reader *pfile, cpp_macro *macro)
 
   /* Is this a parameter?  */
   if (token->type == CPP_NAME
-      && (token->val.node->flags & NODE_MACRO_ARG) != 0)
+      && (token->val.node.node->flags & NODE_MACRO_ARG) != 0)
     {
       token->type = CPP_MACRO_ARG;
-      token->val.arg_no = token->val.node->value.arg_index;
+      token->val.macro_arg.arg_no = token->val.node.node->value.arg_index;
     }
   else if (CPP_WTRADITIONAL (pfile) && macro->paramc > 0
           && (token->type == CPP_STRING || token->type == CPP_CHAR))
@@ -1771,7 +1776,7 @@ create_iso_definition (cpp_reader *pfile, cpp_macro *macro)
            {
              macro->extra_tokens = 1;
              num_extra_tokens++;
-             token->val.arg_no = macro->count - 1;
+             token->val.token_no = macro->count - 1;
            }
          else
            {
@@ -1890,10 +1895,14 @@ _cpp_create_definition (cpp_reader *pfile, cpp_hashnode *node)
 
       if (warn_of_redefinition (pfile, node, macro))
        {
+          const int reason = (node->flags & NODE_BUILTIN)
+                             ? CPP_W_BUILTIN_MACRO_REDEFINED : CPP_W_NONE;
          bool warned;
-         warned = cpp_error_with_line (pfile, CPP_DL_PEDWARN,
-                                       pfile->directive_line, 0,
-                                       "\"%s\" redefined", NODE_NAME (node));
+
+         warned = cpp_pedwarning_with_line (pfile, reason,
+                                            pfile->directive_line, 0,
+                                            "\"%s\" redefined",
+                                             NODE_NAME (node));
 
          if (warned && node->type == NT_MACRO && !(node->flags & NODE_BUILTIN))
            cpp_error_with_line (pfile, CPP_DL_NOTE,
@@ -2007,7 +2016,7 @@ cpp_macro_definition (cpp_reader *pfile, const cpp_hashnode *node)
          cpp_token *token = &macro->exp.tokens[i];
 
          if (token->type == CPP_MACRO_ARG)
-           len += NODE_LEN (macro->params[token->val.arg_no - 1]);
+           len += NODE_LEN (macro->params[token->val.macro_arg.arg_no - 1]);
          else
            len += cpp_token_len (token);
 
@@ -2079,9 +2088,9 @@ cpp_macro_definition (cpp_reader *pfile, const cpp_hashnode *node)
          if (token->type == CPP_MACRO_ARG)
            {
              memcpy (buffer,
-                     NODE_NAME (macro->params[token->val.arg_no - 1]),
-                     NODE_LEN (macro->params[token->val.arg_no - 1]));
-             buffer += NODE_LEN (macro->params[token->val.arg_no - 1]);
+                     NODE_NAME (macro->params[token->val.macro_arg.arg_no - 1]),
+                     NODE_LEN (macro->params[token->val.macro_arg.arg_no - 1]));
+             buffer += NODE_LEN (macro->params[token->val.macro_arg.arg_no - 1]);
            }
          else
            buffer = cpp_spell_token (pfile, token, buffer, false);