Пример #1
0
static enum cpp_ttype
mep_pragma_lex (tree *valp)
{
  enum cpp_ttype t = pragma_lex (valp);
  if (t == CPP_EOF)
    t = CPP_PRAGMA_EOL;
  return t;
}
Пример #2
0
/* Parse a #pragma whose sole argument is a string constant.
   If OPT is true, the argument is optional.  */
static tree
parse_strconst_pragma (const char* name, int opt)
{
  tree result, x;
  enum cpp_ttype t;

  t = pragma_lex (&result);
  if (t == CPP_STRING)
    {
      if (pragma_lex (&x) != CPP_EOF)
	warning (0, "junk at end of #pragma %s", name);
      return result;
    }

  if (t == CPP_EOF && opt)
    return NULL_TREE;

  error ("invalid #pragma %s", name);
  return error_mark_node;
}
Пример #3
0
/* handler function for the config pragma */
void
mchp_handle_config_pragma (struct cpp_reader *pfile)
{
  enum cpp_ttype tok;
  tree tok_value;
  static int shown_no_config_warning = 0;

  /* If we're compiling for the default device, we don't process
     configuration words */
  if (!mchp_processor_string)
    {
      error ("#pragma config directive not available for the default generic device, %s", mchp_processor_string);
      CLEAR_REST_OF_INPUT_LINE();
      return;
    }

  if (!mchp_config_data_dir)
    {
      error ("Configuration-word data directory not specified "
             "but required for #pragma config directive");
      CLEAR_REST_OF_INPUT_LINE();
      return;
    }

  /* the first time we see a config pragma, we need to load the
     configuration word data from the definition file. */
  if (!mchp_configuration_values)
    {
      /* alloc space for the filename: directory + '/' + "configuration.data"
       */
      char *fname = (char*)alloca (strlen (mchp_config_data_dir) + 1 +
                            strlen (MCHP_CONFIGURATION_DATA_FILENAME));
      strcpy (fname, mchp_config_data_dir);
      if (fname [strlen (fname) - 1] != '/'
          && fname [strlen (fname) - 1] != '\\')
        strcat (fname, "/");
      strcat (fname, MCHP_CONFIGURATION_DATA_FILENAME);

      if (mchp_load_configuration_definition (fname))
        {
          if (!shown_no_config_warning)
            {
              shown_no_config_warning = 1;
              warning (0, "configuration word information not available for "
                       "this processor. #pragma config is ignored.");
            }
          CLEAR_REST_OF_INPUT_LINE();
          return;
        }
    }

  /* The payload for the config pragma is a comma delimited list of
     "setting = value" pairs. Both the setting and the value must
     be valid C identifiers. */
  tok = pragma_lex (&tok_value);
  while (1)
    {
      const cpp_token *raw_token;
      const char *setting_name;
      const char *value_name;

      /* the current token should be the setting name */
      if (tok != CPP_NAME)
        {
          error ("configuration setting name expected in configuration pragma");
          break;
        }

      setting_name = IDENTIFIER_POINTER (tok_value);
      /* the next token should be the '=' */
      tok = pragma_lex (&tok_value);
      if (tok != CPP_EQ)
        {
          error ("'=' expected in configuration pragma");
          break;
        }
      /* now we have the value name. We don't use pragma_lex() to get this one
         since we don't want the additional interpretation going on there.
         i.e., converting integers from the string. */
      raw_token = cpp_get_token (pfile);

      if (raw_token->type == CPP_NAME)
        {
        /*
          value_name = IDENTIFIER_POINTER (
                         HT_IDENT_TO_GCC_IDENT (
                         HT_NODE (raw_token->val.node)));
           space?              */
          value_name = cpp_token_as_text (pfile, raw_token);

        }
      else if (raw_token->type == CPP_NUMBER)
        {
          value_name = (char*)raw_token->val.str.text;
        }
      else
        {
          error ("configuration value name expected in configuration pragma");
          break;
        }

      mchp_handle_configuration_setting (setting_name, value_name);

      /* if the next token is ',' then we have another setting. */
      tok = pragma_lex (&tok_value);
      if (tok == CPP_COMMA)
        tok = pragma_lex (&tok_value);
      /* if it's EOF, we're done */
      else if (tok == CPP_EOF)
        break;
      /* otherwise, we have spurious input */
      else
        {
          error ("',' or end of line expected in configuration pragma");
          break;
        }
    }
  /* if we ended for any reason other than end of line, we have an error.
     Any needed diagnostic should have already been issued, so just
     clear the rest of the data on the line. */
  if (tok != CPP_EOF)
    CLEAR_REST_OF_INPUT_LINE();
}
Пример #4
0
#include "c-family/c-common.h"
#include "c-family/c-pragma.h"
#include "diagnostic-core.h"
#include "tm_p.h"

static void ia64_hpux_add_pragma_builtin (tree func);

void
ia64_hpux_handle_builtin_pragma (cpp_reader *pfile ATTRIBUTE_UNUSED)
{
  /* #pragma builtin name, name, name */

  enum cpp_ttype type;
  tree x;

  type = pragma_lex (&x);
  while (type == CPP_NAME)
    {
      ia64_hpux_add_pragma_builtin (x);
      type = pragma_lex (&x);
      if (type == CPP_COMMA)
	type = pragma_lex (&x);
    }
  if (type != CPP_EOF)
    warning (OPT_Wpragmas, "malformed #pragma builtin");
}

/* List of standard math functions which do not set matherr by default
   and which have a different version which does set errno and which we
   want to call *if* we have seen an extern for the routine and we have
   asked for strict C89 compatibility.  */
Пример #5
0
/* Implements the "GCC memregs" pragma.  This pragma takes only an
   integer, and is semantically identical to the -memregs= command
   line option.  The only catch is, the programmer should only use
   this pragma at the beginning of the file (preferably, in some
   project-wide header) to avoid ABI changes related to changing the
   list of available "registers".  */
static void
m32c_pragma_memregs (cpp_reader * reader ATTRIBUTE_UNUSED)
{
  /* on off */
  tree val;
  enum cpp_ttype type;
  HOST_WIDE_INT i;

  type = pragma_lex (&val);
  if (type == CPP_NUMBER)
    {
      if (tree_fits_uhwi_p (val))
	{
	  i = tree_to_uhwi (val);

	  type = pragma_lex (&val);
	  if (type != CPP_EOF)
	    warning (0, "junk at end of #pragma GCC memregs [0..16]");

	  if (i >= 0 && i <= 16)
	    {
	      if (!ok_to_change_target_memregs)
		{
		  warning (0,
Пример #6
0
static int parse_pragma_line
(struct cpp_reader* reader, pragma_type_t type)
{
    pragma_expr_t* const px = alloc_add_pragma_expr();

    if (px == NULL) return 0;
    px->type = type;
    px->file = xstrdup(LOCATION_FILE(input_location));
    px->line = LOCATION_LINE(input_location);

#if 0 /* debug */
    printf("pragma: %s/%u\n", px->file, px->line);
#endif

#if 0 /* TODO */

    while (1)
    {
        /* in cpplib.h */
        tree expr;
        const enum cpp_ttype ttype = pragma_lex(&expr);

        switch (ttype)
        {
        case CPP_PRAGMA_EOL:
        case CPP_EOF:
            goto on_done;
            break ;

        case CPP_COMMA:
            printf(",");
            break ;

        case CPP_OPEN_PAREN:
            printf("(");
            break ;

        case CPP_CLOSE_PAREN:
            printf(")");
            break ;

        case CPP_STRING:
            printf("str<%s>", TREE_STRING_POINTER(expr));
            break ;

        case CPP_NAME:
            printf("nam<%s>", IDENTIFIER_POINTER(expr));
            break ;

        default:
            printf("unk<%u>", ttype);
            break ;
        }
    }

on_done:
    printf("\n");

#endif /* TODO */


    return 0;
}