static void
pp_c_bool_constant (c_pretty_printer *pp, tree b)
{
  if (b == boolean_false_node)
    {
      if (c_dialect_cxx ())
	pp_c_identifier (pp, "false");
      else if (flag_isoc99)
	pp_c_identifier (pp, "_False");
      else
	pp_unsupported_tree (pp, b);
    }
  else if (b == boolean_true_node)
    {
      if (c_dialect_cxx ())
	pp_c_identifier (pp, "true");
      else if (flag_isoc99)
	pp_c_identifier (pp, "_True");
      else
	pp_unsupported_tree (pp, b);
    }
  else if (TREE_CODE (b) == INTEGER_CST)
    pp_c_integer_constant (pp, b);
  else
    pp_unsupported_tree (pp, b);
}
Exemple #2
0
/* Common initialization before parsing options.  */
unsigned int
c_common_init_options (unsigned int argc, const char **argv)
{
  static const unsigned int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX};
  unsigned int i, result;

  /* This is conditionalized only because that is the way the front
     ends used to do it.  Maybe this should be unconditional?  */
  if (c_dialect_cxx ())
    {
      /* By default wrap lines at 80 characters.  Is getenv
	 ("COLUMNS") preferable?  */
      diagnostic_line_cutoff (global_dc) = 80;
      /* By default, emit location information once for every
	 diagnostic message.  */
      diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
    }

  parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
				ident_hash, &line_table);

  cpp_opts = cpp_get_options (parse_in);
  cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
  cpp_opts->objc = c_dialect_objc ();

  /* Reset to avoid warnings on internal definitions.  We set it just
     before passing on command-line options to cpplib.  */
  cpp_opts->warn_dollars = 0;

  flag_exceptions = c_dialect_cxx ();
  warn_pointer_arith = c_dialect_cxx ();
  warn_write_strings = c_dialect_cxx();

  deferred_opts = XNEWVEC (struct deferred_opt, argc);

  result = lang_flags[c_language];

  if (c_language == clk_c)
    {
      /* If preprocessing assembly language, accept any of the C-family
	 front end options since the driver may pass them through.  */
      for (i = 1; i < argc; i++)
	if (! strcmp (argv[i], "-lang-asm"))
	  {
	    result |= CL_C | CL_ObjC | CL_CXX | CL_ObjCXX;
	    break;
	  }

#ifdef CL_Fortran
      for (i = 1; i < argc; i++)
	if (! strcmp (argv[i], "-lang-fortran"))
	{
	    result |= CL_Fortran;
	    break;
	}
#endif
    }

  return result;
}
Exemple #3
0
/* Initialize options structure OPTS.  */
void
c_common_init_options_struct (struct gcc_options *opts)
{
  opts->x_flag_exceptions = c_dialect_cxx ();
  opts->x_warn_pointer_arith = c_dialect_cxx ();
  opts->x_warn_write_strings = c_dialect_cxx ();
  opts->x_flag_warn_unused_result = true;

  /* By default, C99-like requirements for complex multiply and divide.  */
  opts->x_flag_complex_method = 2;
}
Exemple #4
0
/* Common initialization before calling option handlers.  */
void
c_common_init_options (unsigned int decoded_options_count,
		       struct cl_decoded_option *decoded_options)
{
  unsigned int i;
  struct cpp_callbacks *cb;

  parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
				ident_hash, line_table);
  cb = cpp_get_callbacks (parse_in);
  cb->error = c_cpp_error;

  cpp_opts = cpp_get_options (parse_in);
  cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
  cpp_opts->objc = c_dialect_objc ();

  /* Reset to avoid warnings on internal definitions.  We set it just
     before passing on command-line options to cpplib.  */
  cpp_opts->warn_dollars = 0;

  deferred_opts = XNEWVEC (struct deferred_opt, decoded_options_count);

  if (c_language == clk_c)
    {
      /* If preprocessing assembly language, accept any of the C-family
	 front end options since the driver may pass them through.  */
      for (i = 1; i < decoded_options_count; i++)
	if (decoded_options[i].opt_index == OPT_lang_asm)
	  {
	    accept_all_c_family_options = true;
	    break;
	  }
    }
}
Exemple #5
0
/* Converts a (possibly wide) character constant token into a tree.  */
static tree
lex_charconst (const cpp_token *token)
{
  cppchar_t result;
  tree type, value;
  unsigned int chars_seen;
  int unsignedp;

  result = cpp_interpret_charconst (parse_in, token,
				    &chars_seen, &unsignedp);

  if (token->type == CPP_WCHAR)
    type = wchar_type_node;
  /* In C, a character constant has type 'int'.
     In C++ 'char', but multi-char charconsts have type 'int'.  */
  else if (!c_dialect_cxx () || chars_seen > 1)
    type = integer_type_node;
  else
    type = char_type_node;

  /* Cast to cppchar_signed_t to get correct sign-extension of RESULT
     before possibly widening to HOST_WIDE_INT for build_int_cst.  */
  if (unsignedp || (cppchar_signed_t) result >= 0)
    value = build_int_cst_wide (type, result, 0);
  else
    value = build_int_cst_wide (type, (cppchar_signed_t) result, -1);

  return value;
}
Exemple #6
0
/* Common initialization before calling option handlers.  */
void
c_common_init_options (unsigned int decoded_options_count,
		       struct cl_decoded_option *decoded_options)
{
  unsigned int i;
  struct cpp_callbacks *cb;

  g_string_concat_db
    = new (ggc_alloc <string_concat_db> ()) string_concat_db ();

  parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
				ident_hash, line_table);
  cb = cpp_get_callbacks (parse_in);
  cb->diagnostic = c_cpp_diagnostic;

  cpp_opts = cpp_get_options (parse_in);
  cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
  cpp_opts->objc = c_dialect_objc ();

  /* Reset to avoid warnings on internal definitions.  We set it just
     before passing on command-line options to cpplib.  */
  cpp_opts->warn_dollars = 0;

  deferred_opts = XNEWVEC (struct deferred_opt, decoded_options_count);

  if (c_language == clk_c)
    {
      /* The default for C is gnu17.  */
      set_std_c17 (false /* ISO */);

      /* If preprocessing assembly language, accept any of the C-family
	 front end options since the driver may pass them through.  */
      for (i = 1; i < decoded_options_count; i++)
	if (decoded_options[i].opt_index == OPT_lang_asm)
	  {
	    accept_all_c_family_options = true;
	    break;
	  }
    }

  /* Set C++ standard to C++14 if not specified on the command line.  */
  if (c_dialect_cxx ())
    set_std_cxx14 (/*ISO*/false);

  global_dc->colorize_source_p = true;
}
Exemple #7
0
/* In addition to calling fold_convert for EXPR of type TYPE, also
   call c_fully_fold to remove any C_MAYBE_CONST_EXPRs that could be
   hiding there (PR47197).  */
tree
fully_fold_convert (tree type, tree expr)
{
  tree result = fold_convert (type, expr);
  bool maybe_const = true;

  if (!c_dialect_cxx ())
    result = c_fully_fold (result, false, &maybe_const);

  return result;
}
void
pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
{
  const enum tree_code code = TREE_CODE (t);

  if (TREE_CODE (t) != POINTER_TYPE)
    pp_c_type_qualifier_list (pp, t);
  switch (code)
    {
    case REFERENCE_TYPE:
    case POINTER_TYPE:
	/* APPLE LOCAL blocks */
	case BLOCK_POINTER_TYPE:
      {
	/* Get the types-specifier of this type.  */
	tree pointee = strip_pointer_operator (TREE_TYPE (t));
	pp_c_specifier_qualifier_list (pp, pointee);
	if (TREE_CODE (pointee) == ARRAY_TYPE
	    || TREE_CODE (pointee) == FUNCTION_TYPE)
	  {
	    pp_c_whitespace (pp);
	    pp_c_left_paren (pp);
	  }
	else if (!c_dialect_cxx ())
	  pp_c_whitespace (pp);
	pp_ptr_operator (pp, t);
      }
      break;

    case FUNCTION_TYPE:
    case ARRAY_TYPE:
      pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
      break;

    case VECTOR_TYPE:
    case COMPLEX_TYPE:
      pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
      if (code == COMPLEX_TYPE)
	pp_c_identifier (pp, flag_isoc99 ? "_Complex" : "__complex__");
      else if (code == VECTOR_TYPE)
	pp_c_identifier (pp, "__vector__");
      break;

    default:
      pp_simple_type_specifier (pp, t);
      break;
    }
}
/* Define __GNUC__, __GNUC_MINOR__ and __GNUC_PATCHLEVEL__.  */
static void
define__GNUC__ (void)
{
  int major, minor, patchlevel;

  if (sscanf (BASEVER, "%d.%d.%d", &major, &minor, &patchlevel) != 3)
    {
      sscanf (BASEVER, "%d.%d", &major, &minor);
      patchlevel = 0;
    }
  cpp_define_formatted (parse_in, "__GNUC__=%d", major);
  cpp_define_formatted (parse_in, "__GNUC_MINOR__=%d", minor);
  cpp_define_formatted (parse_in, "__GNUC_PATCHLEVEL__=%d", patchlevel);

  if (c_dialect_cxx ())
    cpp_define_formatted (parse_in, "__GNUG__=%d", major);
}
Exemple #10
0
/* Common diagnostics initialization.  */
void
c_common_initialize_diagnostics (diagnostic_context *context)
{
  /* This is conditionalized only because that is the way the front
     ends used to do it.  Maybe this should be unconditional?  */
  if (c_dialect_cxx ())
    {
      /* By default wrap lines at 80 characters.  Is getenv
	 ("COLUMNS") preferable?  */
      diagnostic_line_cutoff (context) = 80;
      /* By default, emit location information once for every
	 diagnostic message.  */
      diagnostic_prefixing_rule (context) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
    }

  context->opt_permissive = OPT_fpermissive;
}
Exemple #11
0
void gcc_plugin_finish_type(void *gcc_data, void *user_data)
{
    tree type = (tree) gcc_data;
    if (TREE_CODE(type) == ERROR_MARK) return;

    tree idnode = TYPE_NAME(type);

    // if the structure was declared with an explicit name then assign it that.
    if (idnode && TREE_CODE(idnode) == IDENTIFIER_NODE) {
        const char *name = IDENTIFIER_POINTER(idnode);
        XIL_CSUName(type, name);
    }

    // for C++ we check the type for a TYPE_DECL name within XIL_CSUName.
    // force this check now so that we don't get confused by any later typedefs.
    if (c_dialect_cxx())
        XIL_CSUName(type, NULL);
}
Exemple #12
0
/* Define __GNUC__, __GNUC_MINOR__ and __GNUC_PATCHLEVEL__.  */
static void
define__GNUC__ (void)
{
  /* The format of the version string, enforced below, is
     ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)?  */
  const char *q, *v = version_string;

  while (*v && ! ISDIGIT (*v))
    v++;
  if (!*v || (v > version_string && v[-1] != '-'))
    abort ();

  q = v;
  while (ISDIGIT (*v))
    v++;
  builtin_define_with_value_n ("__GNUC__", q, v - q);
  if (c_dialect_cxx ())
    builtin_define_with_value_n ("__GNUG__", q, v - q);

  if (*v != '.' || !ISDIGIT (v[1]))
    abort ();
  q = ++v;
  while (ISDIGIT (*v))
    v++;
  builtin_define_with_value_n ("__GNUC_MINOR__", q, v - q);

  if (*v == '.')
    {
      if (!ISDIGIT (v[1]))
	abort ();
      q = ++v;
      while (ISDIGIT (*v))
	v++;
      builtin_define_with_value_n ("__GNUC_PATCHLEVEL__", q, v - q);
    }
  else
    builtin_define_with_value_n ("__GNUC_PATCHLEVEL__", "0", 1);

  if (*v && *v != ' ' && *v != '-')
    abort ();
}
Exemple #13
0
/* Hook that registers front end and target-specific built-ins.  */
void
c_cpp_builtins (cpp_reader *pfile)
{
  /* -undef turns off target-specific built-ins.  */
  if (flag_undef)
    return;

  define_language_independent_builtin_macros (pfile);

  if (c_dialect_cxx ())
  {
    int major;
    parse_basever (&major, NULL, NULL);
    cpp_define_formatted (pfile, "__GNUG__=%d", major);
  }

  /* For stddef.h.  They require macros defined in c-common.c.  */
  c_stddef_cpp_builtins ();

  /* Set include test macros for all C/C++ (not for just C++11 etc.)
     the builtins __has_include__ and __has_include_next__ are defined
     in libcpp.  */
  cpp_define (pfile, "__has_include(STR)=__has_include__(STR)");
  cpp_define (pfile, "__has_include_next(STR)=__has_include_next__(STR)");

  if (c_dialect_cxx ())
    {
      if (flag_weak && SUPPORTS_ONE_ONLY)
	cpp_define (pfile, "__GXX_WEAK__=1");
      else
	cpp_define (pfile, "__GXX_WEAK__=0");

      if (warn_deprecated)
	cpp_define (pfile, "__DEPRECATED");

      if (flag_rtti)
	cpp_define (pfile, "__GXX_RTTI");

      if (cxx_dialect >= cxx11)
        cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__");

      /* Binary literals have been allowed in g++ before C++11
	 and were standardized for C++14.  */
      if (!pedantic || cxx_dialect > cxx11)
	cpp_define (pfile, "__cpp_binary_literals=201304");
      if (cxx_dialect >= cxx11)
	{
	  /* Set feature test macros for C++11  */
	  cpp_define (pfile, "__cpp_unicode_characters=200704");
	  cpp_define (pfile, "__cpp_raw_strings=200710");
	  cpp_define (pfile, "__cpp_unicode_literals=200710");
	  cpp_define (pfile, "__cpp_user_defined_literals=200809");
	  cpp_define (pfile, "__cpp_lambdas=200907");
	  cpp_define (pfile, "__cpp_constexpr=200704");
	  cpp_define (pfile, "__cpp_static_assert=200410");
	  cpp_define (pfile, "__cpp_decltype=200707");
	  cpp_define (pfile, "__cpp_attributes=200809");
	  cpp_define (pfile, "__cpp_rvalue_reference=200610");
	  cpp_define (pfile, "__cpp_variadic_templates=200704");
	  cpp_define (pfile, "__cpp_alias_templates=200704");
	}
      if (cxx_dialect > cxx11)
	{
	  /* Set feature test macros for C++14  */
	  cpp_define (pfile, "__cpp_return_type_deduction=201304");
	  cpp_define (pfile, "__cpp_init_captures=201304");
	  cpp_define (pfile, "__cpp_generic_lambdas=201304");
	  //cpp_undef (pfile, "__cpp_constexpr");
	  //cpp_define (pfile, "__cpp_constexpr=201304");
	  cpp_define (pfile, "__cpp_decltype_auto=201304");
	  //cpp_define (pfile, "__cpp_aggregate_nsdmi=201304");
	  //cpp_define (pfile, "__cpp_variable_templates=201304");
	  cpp_define (pfile, "__cpp_digit_separators=201309");
	  cpp_define (pfile, "__cpp_attribute_deprecated=201309");
	  //cpp_define (pfile, "__cpp_sized_deallocation=201309");
	  /* We'll have to see where runtime arrays wind up.
	     Let's put it in C++14 for now.  */
	  cpp_define (pfile, "__cpp_runtime_arrays=201304");
	}
    }
  /* Note that we define this for C as well, so that we know if
     __attribute__((cleanup)) will interface with EH.  */
  if (flag_exceptions)
    cpp_define (pfile, "__EXCEPTIONS");

  /* Represents the C++ ABI version, always defined so it can be used while
     preprocessing C and assembler.  */
  if (flag_abi_version == 0)
    /* Use a very large value so that:

	 #if __GXX_ABI_VERSION >= <value for version X>

       will work whether the user explicitly says "-fabi-version=x" or
       "-fabi-version=0".  Do not use INT_MAX because that will be
       different from system to system.  */
    builtin_define_with_int_value ("__GXX_ABI_VERSION", 999999);
  else if (flag_abi_version == 1)
    /* Due to a historical accident, this version had the value
       "102".  */
    builtin_define_with_int_value ("__GXX_ABI_VERSION", 102);
  else
    /* Newer versions have values 1002, 1003, ....  */
    builtin_define_with_int_value ("__GXX_ABI_VERSION",
				   1000 + flag_abi_version);

  /* libgcc needs to know this.  */
  if (targetm_common.except_unwind_info (&global_options) == UI_SJLJ)
    cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__");

  /* limits.h and stdint.h need to know these.  */
  builtin_define_type_max ("__SCHAR_MAX__", signed_char_type_node);
  builtin_define_type_max ("__SHRT_MAX__", short_integer_type_node);
  builtin_define_type_max ("__INT_MAX__", integer_type_node);
  builtin_define_type_max ("__LONG_MAX__", long_integer_type_node);
  builtin_define_type_max ("__LONG_LONG_MAX__", long_long_integer_type_node);
  builtin_define_type_minmax ("__WCHAR_MIN__", "__WCHAR_MAX__",
			      underlying_wchar_type_node);
  builtin_define_type_minmax ("__WINT_MIN__", "__WINT_MAX__", wint_type_node);
  builtin_define_type_max ("__PTRDIFF_MAX__", ptrdiff_type_node);
  builtin_define_type_max ("__SIZE_MAX__", size_type_node);

  /* stdint.h and the testsuite need to know these.  */
  builtin_define_stdint_macros ();

  /* Provide information for library headers to determine whether to
     define macros such as __STDC_IEC_559__ and
     __STDC_IEC_559_COMPLEX__.  */
  builtin_define_with_int_value ("__GCC_IEC_559", cpp_iec_559_value ());
  builtin_define_with_int_value ("__GCC_IEC_559_COMPLEX",
				 cpp_iec_559_complex_value ());

  /* float.h needs to know this.  */
  builtin_define_with_int_value ("__FLT_EVAL_METHOD__",
				 TARGET_FLT_EVAL_METHOD);

  /* And decfloat.h needs this.  */
  builtin_define_with_int_value ("__DEC_EVAL_METHOD__",
                                 TARGET_DEC_EVAL_METHOD);

  builtin_define_float_constants ("FLT", "F", "%s", "F", float_type_node);
  /* Cast the double precision constants.  This is needed when single
     precision constants are specified or when pragma FLOAT_CONST_DECIMAL64
     is used.  The correct result is computed by the compiler when using
     macros that include a cast.  We use a different cast for C++ to avoid
     problems with -Wold-style-cast.  */
  builtin_define_float_constants ("DBL", "L",
				  (c_dialect_cxx ()
				   ? "double(%s)"
				   : "((double)%s)"),
				  "", double_type_node);
  builtin_define_float_constants ("LDBL", "L", "%s", "L",
				  long_double_type_node);

  /* For decfloat.h.  */
  builtin_define_decimal_float_constants ("DEC32", "DF", dfloat32_type_node);
  builtin_define_decimal_float_constants ("DEC64", "DD", dfloat64_type_node);
  builtin_define_decimal_float_constants ("DEC128", "DL", dfloat128_type_node);

  /* For fixed-point fibt, ibit, max, min, and epsilon.  */
  if (targetm.fixed_point_supported_p ())
    {
      builtin_define_fixed_point_constants ("SFRACT", "HR",
					    short_fract_type_node);
      builtin_define_fixed_point_constants ("USFRACT", "UHR",
					    unsigned_short_fract_type_node);
      builtin_define_fixed_point_constants ("FRACT", "R",
					    fract_type_node);
      builtin_define_fixed_point_constants ("UFRACT", "UR",
					    unsigned_fract_type_node);
      builtin_define_fixed_point_constants ("LFRACT", "LR",
					    long_fract_type_node);
      builtin_define_fixed_point_constants ("ULFRACT", "ULR",
					    unsigned_long_fract_type_node);
      builtin_define_fixed_point_constants ("LLFRACT", "LLR",
					    long_long_fract_type_node);
      builtin_define_fixed_point_constants ("ULLFRACT", "ULLR",
					    unsigned_long_long_fract_type_node);
      builtin_define_fixed_point_constants ("SACCUM", "HK",
					    short_accum_type_node);
      builtin_define_fixed_point_constants ("USACCUM", "UHK",
					    unsigned_short_accum_type_node);
      builtin_define_fixed_point_constants ("ACCUM", "K",
					    accum_type_node);
      builtin_define_fixed_point_constants ("UACCUM", "UK",
					    unsigned_accum_type_node);
      builtin_define_fixed_point_constants ("LACCUM", "LK",
					    long_accum_type_node);
      builtin_define_fixed_point_constants ("ULACCUM", "ULK",
					    unsigned_long_accum_type_node);
      builtin_define_fixed_point_constants ("LLACCUM", "LLK",
					    long_long_accum_type_node);
      builtin_define_fixed_point_constants ("ULLACCUM", "ULLK",
					    unsigned_long_long_accum_type_node);

      builtin_define_fixed_point_constants ("QQ", "", qq_type_node);
      builtin_define_fixed_point_constants ("HQ", "", hq_type_node);
      builtin_define_fixed_point_constants ("SQ", "", sq_type_node);
      builtin_define_fixed_point_constants ("DQ", "", dq_type_node);
      builtin_define_fixed_point_constants ("TQ", "", tq_type_node);
      builtin_define_fixed_point_constants ("UQQ", "", uqq_type_node);
      builtin_define_fixed_point_constants ("UHQ", "", uhq_type_node);
      builtin_define_fixed_point_constants ("USQ", "", usq_type_node);
      builtin_define_fixed_point_constants ("UDQ", "", udq_type_node);
      builtin_define_fixed_point_constants ("UTQ", "", utq_type_node);
      builtin_define_fixed_point_constants ("HA", "", ha_type_node);
      builtin_define_fixed_point_constants ("SA", "", sa_type_node);
      builtin_define_fixed_point_constants ("DA", "", da_type_node);
      builtin_define_fixed_point_constants ("TA", "", ta_type_node);
      builtin_define_fixed_point_constants ("UHA", "", uha_type_node);
      builtin_define_fixed_point_constants ("USA", "", usa_type_node);
      builtin_define_fixed_point_constants ("UDA", "", uda_type_node);
      builtin_define_fixed_point_constants ("UTA", "", uta_type_node);
    }

  /* For libgcc-internal use only.  */
  if (flag_building_libgcc)
    /* For libgcc enable-execute-stack.c.  */
    builtin_define_with_int_value ("__LIBGCC_TRAMPOLINE_SIZE__",
				   TRAMPOLINE_SIZE);

  /* For use in assembly language.  */
  builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
  builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);

  /* Misc.  */
  if (flag_gnu89_inline)
    cpp_define (pfile, "__GNUC_GNU_INLINE__");
  else
    cpp_define (pfile, "__GNUC_STDC_INLINE__");

  if (flag_no_inline)
    cpp_define (pfile, "__NO_INLINE__");

  if (flag_iso)
    cpp_define (pfile, "__STRICT_ANSI__");

  if (!flag_signed_char)
    cpp_define (pfile, "__CHAR_UNSIGNED__");

  if (c_dialect_cxx () && TYPE_UNSIGNED (wchar_type_node))
    cpp_define (pfile, "__WCHAR_UNSIGNED__");

  /* Tell source code if the compiler makes sync_compare_and_swap
     builtins available.  */
#ifdef HAVE_sync_compare_and_swapqi
  if (HAVE_sync_compare_and_swapqi)
    cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
#endif

#ifdef HAVE_sync_compare_and_swaphi
  if (HAVE_sync_compare_and_swaphi)
    cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
#endif

#ifdef HAVE_sync_compare_and_swapsi
  if (HAVE_sync_compare_and_swapsi)
    cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
#endif

#ifdef HAVE_sync_compare_and_swapdi
  if (HAVE_sync_compare_and_swapdi)
    cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
#endif

#ifdef HAVE_sync_compare_and_swapti
  if (HAVE_sync_compare_and_swapti)
    cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");
#endif

  cpp_atomic_builtins (pfile);
    
#ifdef DWARF2_UNWIND_INFO
  if (dwarf2out_do_cfi_asm ())
    cpp_define (pfile, "__GCC_HAVE_DWARF2_CFI_ASM");
#endif

  /* Make the choice of ObjC runtime visible to source code.  */
  if (c_dialect_objc () && flag_next_runtime)
    cpp_define (pfile, "__NEXT_RUNTIME__");

  /* Show the availability of some target pragmas.  */
  cpp_define (pfile, "__PRAGMA_REDEFINE_EXTNAME");

  /* Make the choice of the stack protector runtime visible to source code.
     The macro names and values here were chosen for compatibility with an
     earlier implementation, i.e. ProPolice.  */
  if (flag_stack_protect == 3)
    cpp_define (pfile, "__SSP_STRONG__=3");
  if (flag_stack_protect == 2)
    cpp_define (pfile, "__SSP_ALL__=2");
  else if (flag_stack_protect == 1)
    cpp_define (pfile, "__SSP__=1");

  if (flag_openmp)
    cpp_define (pfile, "_OPENMP=201307");

  if (int128_integer_type_node != NULL_TREE)
    builtin_define_type_sizeof ("__SIZEOF_INT128__",
			        int128_integer_type_node);
  builtin_define_type_sizeof ("__SIZEOF_WCHAR_T__", wchar_type_node);
  builtin_define_type_sizeof ("__SIZEOF_WINT_T__", wint_type_node);
  builtin_define_type_sizeof ("__SIZEOF_PTRDIFF_T__",
			      unsigned_ptrdiff_type_node);

  /* A straightforward target hook doesn't work, because of problems
     linking that hook's body when part of non-C front ends.  */
# define preprocessing_asm_p() (cpp_get_options (pfile)->lang == CLK_ASM)
# define preprocessing_trad_p() (cpp_get_options (pfile)->traditional)
# define builtin_define(TXT) cpp_define (pfile, TXT)
# define builtin_assert(TXT) cpp_assert (pfile, TXT)
  TARGET_CPU_CPP_BUILTINS ();
  TARGET_OS_CPP_BUILTINS ();
  TARGET_OBJFMT_CPP_BUILTINS ();

  /* Support the __declspec keyword by turning them into attributes.
     Note that the current way we do this may result in a collision
     with predefined attributes later on.  This can be solved by using
     one attribute, say __declspec__, and passing args to it.  The
     problem with that approach is that args are not accumulated: each
     new appearance would clobber any existing args.  */
  if (TARGET_DECLSPEC)
    builtin_define ("__declspec(x)=__attribute__((x))");

  /* If decimal floating point is supported, tell the user if the
     alternate format (BID) is used instead of the standard (DPD)
     format.  */
  if (ENABLE_DECIMAL_FLOAT && ENABLE_DECIMAL_BID_FORMAT)
    cpp_define (pfile, "__DECIMAL_BID_FORMAT__");
  if (c_dialect_cxx () && flag_sized_delete)
    cpp_define (pfile, "__GXX_DELETE_WITH_SIZE__");
}
Exemple #14
0
/* Handle switch SCODE with argument ARG.  VALUE is true, unless no-
   form of an -f or -W option was given.  Returns 0 if the switch was
   invalid, a negative number to prevent language-independent
   processing in toplev.c (a hack necessary for the short-term).  */
int
c_common_handle_option (size_t scode, const char *arg, int value)
{
  const struct cl_option *option = &cl_options[scode];
  enum opt_code code = (enum opt_code) scode;
  int result = 1;

  /* Prevent resetting the language standard to a C dialect when the driver
     has already determined that we're looking at assembler input.  */
  bool preprocessing_asm_p = (cpp_get_options (parse_in)->lang == CLK_ASM);
 
  switch (code)
    {
    default:
      if (cl_options[code].flags & (CL_C | CL_CXX | CL_ObjC | CL_ObjCXX))
	break;
#ifdef CL_Fortran
      if (lang_fortran && (cl_options[code].flags & (CL_Fortran)))
	break;
#endif
      result = 0;
      break;

    case OPT__output_pch_:
      pch_file = arg;
      break;

    case OPT_A:
      defer_opt (code, arg);
      break;

    case OPT_C:
      cpp_opts->discard_comments = 0;
      break;

    case OPT_CC:
      cpp_opts->discard_comments = 0;
      cpp_opts->discard_comments_in_macro_exp = 0;
      break;

    case OPT_D:
      defer_opt (code, arg);
      break;

    case OPT_E:
      flag_preprocess_only = 1;
      break;

    case OPT_H:
      cpp_opts->print_include_names = 1;
      break;

    case OPT_F:
      TARGET_OPTF (xstrdup (arg));
      break;

    case OPT_I:
      if (strcmp (arg, "-"))
	add_path (xstrdup (arg), BRACKET, 0, true);
      else
	{
	  if (quote_chain_split)
	    error ("-I- specified twice");
	  quote_chain_split = true;
	  split_quote_chain ();
	  inform ("obsolete option -I- used, please use -iquote instead");
	}
      break;

    case OPT_M:
    case OPT_MM:
      /* When doing dependencies with -M or -MM, suppress normal
	 preprocessed output, but still do -dM etc. as software
	 depends on this.  Preprocessed output does occur if -MD, -MMD
	 or environment var dependency generation is used.  */
      cpp_opts->deps.style = (code == OPT_M ? DEPS_SYSTEM: DEPS_USER);
      flag_no_output = 1;
      cpp_opts->inhibit_warnings = 1;
      break;

    case OPT_MD:
    case OPT_MMD:
      cpp_opts->deps.style = (code == OPT_MD ? DEPS_SYSTEM: DEPS_USER);
      deps_file = arg;
      break;

    case OPT_MF:
      deps_seen = true;
      deps_file = arg;
      break;

    case OPT_MG:
      deps_seen = true;
      cpp_opts->deps.missing_files = true;
      break;

    case OPT_MP:
      deps_seen = true;
      cpp_opts->deps.phony_targets = true;
      break;

    case OPT_MQ:
    case OPT_MT:
      deps_seen = true;
      defer_opt (code, arg);
      break;

    case OPT_P:
      flag_no_line_commands = 1;
      break;

    case OPT_fworking_directory:
      flag_working_directory = value;
      break;

    case OPT_U:
      defer_opt (code, arg);
      break;

    case OPT_Wall:
      /* APPLE LOCAL -Wmost */
    case OPT_Wmost:
      set_Wunused (value);
      set_Wformat (value);
      set_Wimplicit (value);
      warn_char_subscripts = value;
      warn_missing_braces = value;
      /* APPLE LOCAL begin -Wmost --dpatel */
      if (code != OPT_Wmost) 
	warn_parentheses = value;
      /* APPLE LOCAL end -Wmost --dpatel */
      warn_return_type = value;
      warn_sequence_point = value;	/* Was C only.  */
      if (c_dialect_cxx ())
	warn_sign_compare = value;
      warn_switch = value;
      set_warn_strict_aliasing (value);
      warn_strict_overflow = value;
      warn_address = value;

      /* Only warn about unknown pragmas that are not in system
	 headers.  */
      warn_unknown_pragmas = value;

      /* We save the value of warn_uninitialized, since if they put
	 -Wuninitialized on the command line, we need to generate a
	 warning about not using it without also specifying -O.  */
      if (warn_uninitialized != 1)
	warn_uninitialized = (value ? 2 : 0);

      if (!c_dialect_cxx ())
	/* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
	   can turn it off only if it's not explicit.  */
	warn_main = value * 2;
      else
	{
	  /* C++-specific warnings.  */
	  warn_reorder = value;
	  warn_nontemplate_friend = value;
	}

      cpp_opts->warn_trigraphs = value;
      cpp_opts->warn_comments = value;
      cpp_opts->warn_num_sign_change = value;
      cpp_opts->warn_multichar = value;	/* Was C++ only.  */

      if (warn_pointer_sign == -1)
	warn_pointer_sign = 1;
      break;

    case OPT_Wcomment:
    case OPT_Wcomments:
      cpp_opts->warn_comments = value;
      break;

    case OPT_Wdeprecated:
      cpp_opts->warn_deprecated = value;
      break;

    case OPT_Wendif_labels:
      cpp_opts->warn_endif_labels = value;
      break;

    case OPT_Werror:
      cpp_opts->warnings_are_errors = value;
      global_dc->warning_as_error_requested = value;
      break;

    case OPT_Werror_implicit_function_declaration:
      mesg_implicit_function_declaration = 2;
      break;

    case OPT_Wformat:
      set_Wformat (value);
      break;

    case OPT_Wformat_:
      set_Wformat (atoi (arg));
      break;

    case OPT_Wimplicit:
      set_Wimplicit (value);
      break;

    case OPT_Wimport:
      /* Silently ignore for now.  */
      break;

    case OPT_Winvalid_pch:
      cpp_opts->warn_invalid_pch = value;
      break;

    case OPT_Wmain:
      if (value)
	warn_main = 1;
      else
	warn_main = -1;
      break;

    case OPT_Wmissing_include_dirs:
      cpp_opts->warn_missing_include_dirs = value;
      break;

    case OPT_Wmultichar:
      cpp_opts->warn_multichar = value;
      break;

      /* APPLE LOCAL begin -Wnewline-eof */
    case OPT_Wnewline_eof:
      cpp_opts->warn_newline_at_eof = value;
      break;
      /* APPLE LOCAL end -Wnewline-eof */

    case OPT_Wnormalized_:
      if (!value || (arg && strcasecmp (arg, "none") == 0))
	cpp_opts->warn_normalize = normalized_none;
      else if (!arg || strcasecmp (arg, "nfkc") == 0)
	cpp_opts->warn_normalize = normalized_KC;
      else if (strcasecmp (arg, "id") == 0)
	cpp_opts->warn_normalize = normalized_identifier_C;
      else if (strcasecmp (arg, "nfc") == 0)
	cpp_opts->warn_normalize = normalized_C;
      else
	error ("argument %qs to %<-Wnormalized%> not recognized", arg);
      break;

    case OPT_Wreturn_type:
      warn_return_type = value;
      break;

    case OPT_Wstrict_null_sentinel:
      warn_strict_null_sentinel = value;
      break;

    case OPT_Wsystem_headers:
      cpp_opts->warn_system_headers = value;
      break;

    case OPT_Wtraditional:
      cpp_opts->warn_traditional = value;
      break;

    case OPT_Wtrigraphs:
      cpp_opts->warn_trigraphs = value;
      break;

    case OPT_Wundef:
      cpp_opts->warn_undef = value;
      break;

    case OPT_Wunknown_pragmas:
      /* Set to greater than 1, so that even unknown pragmas in
	 system headers will be warned about.  */
      warn_unknown_pragmas = value * 2;
      break;

    case OPT_Wunused_macros:
      warn_unused_macros = value;
      break;

    case OPT_Wvariadic_macros:
      warn_variadic_macros = value;
      break;

    case OPT_Wwrite_strings:
      warn_write_strings = value;
      break;

    case OPT_Weffc__:
      warn_ecpp = value;
      if (value)
        warn_nonvdtor = true;
      break;

    case OPT_ansi:
      if (!c_dialect_cxx ())
	set_std_c89 (false, true);
      else
	set_std_cxx98 (true);
      break;

    case OPT_d:
      handle_OPT_d (arg);
      break;

    case OPT_fcond_mismatch:
      if (!c_dialect_cxx ())
	{
	  flag_cond_mismatch = value;
	  break;
	}
      /* Fall through.  */

    case OPT_fall_virtual:
    case OPT_falt_external_templates:
    case OPT_fenum_int_equiv:
    case OPT_fexternal_templates:
    case OPT_fguiding_decls:
    case OPT_fhonor_std:
    case OPT_fhuge_objects:
    case OPT_flabels_ok:
    case OPT_fname_mangling_version_:
    case OPT_fnew_abi:
    case OPT_fnonnull_objects:
    case OPT_fsquangle:
    case OPT_fstrict_prototype:
    case OPT_fthis_is_variable:
    case OPT_fvtable_thunks:
    case OPT_fxref:
    case OPT_fvtable_gc:
      warning (0, "switch %qs is no longer supported", option->opt_text);
      break;

    case OPT_faccess_control:
      flag_access_control = value;
      break;

    case OPT_fasm:
      flag_no_asm = !value;
      break;

    case OPT_fbuiltin:
      flag_no_builtin = !value;
      break;

    case OPT_fbuiltin_:
      if (value)
	result = 0;
      else
	disable_builtin_function (arg);
      break;

    case OPT_fdirectives_only:
      cpp_opts->directives_only = 1;
      break;

    case OPT_fdollars_in_identifiers:
      cpp_opts->dollars_in_ident = value;
      break;

    case OPT_ffreestanding:
      value = !value;
      /* Fall through....  */
    case OPT_fhosted:
      flag_hosted = value;
      flag_no_builtin = !value;
      /* warn_main will be 2 if set by -Wall, 1 if set by -Wmain */
      if (!value && warn_main == 2)
	warn_main = 0;
      break;

    case OPT_fshort_double:
      flag_short_double = value;
      break;

    case OPT_fshort_enums:
      flag_short_enums = value;
      break;

    case OPT_fshort_wchar:
      flag_short_wchar = value;
      break;

    case OPT_fsigned_bitfields:
      flag_signed_bitfields = value;
      break;

    case OPT_fsigned_char:
      flag_signed_char = value;
      break;

    case OPT_funsigned_bitfields:
      flag_signed_bitfields = !value;
      break;

    case OPT_funsigned_char:
      flag_signed_char = !value;
      break;

    case OPT_fcheck_new:
      flag_check_new = value;
      break;

    case OPT_fconserve_space:
      flag_conserve_space = value;
      break;

    case OPT_fconstant_string_class_:
      constant_string_class_name = arg;
      break;

    case OPT_fdefault_inline:
      flag_default_inline = value;
      break;

    case OPT_felide_constructors:
      flag_elide_constructors = value;
      break;

    case OPT_fenforce_eh_specs:
      flag_enforce_eh_specs = value;
      break;

    case OPT_fextended_identifiers:
      cpp_opts->extended_identifiers = value;
      break;

    case OPT_ffor_scope:
      flag_new_for_scope = value;
      break;

    case OPT_fgnu_keywords:
      flag_no_gnu_keywords = !value;
      break;

    case OPT_fgnu_runtime:
      flag_next_runtime = !value;
      break;

    case OPT_fhandle_exceptions:
      warning (0, "-fhandle-exceptions has been renamed -fexceptions (and is now on by default)");
      flag_exceptions = value;
      break;

    case OPT_fimplement_inlines:
      flag_implement_inlines = value;
      break;

    case OPT_fimplicit_inline_templates:
      flag_implicit_inline_templates = value;
      break;

    case OPT_fimplicit_templates:
      flag_implicit_templates = value;
      break;

    case OPT_flax_vector_conversions:
      flag_lax_vector_conversions = value;
      break;

    case OPT_fms_extensions:
      flag_ms_extensions = value;
      break;

    case OPT_fnext_runtime:
      flag_next_runtime = value;
      break;

    case OPT_fnil_receivers:
      flag_nil_receivers = value;
      break;

    case OPT_fnonansi_builtins:
      flag_no_nonansi_builtin = !value;
      break;

    case OPT_foperator_names:
      cpp_opts->operator_names = value;
      break;

    case OPT_foptional_diags:
      flag_optional_diags = value;
      break;

    case OPT_fpch_deps:
      cpp_opts->restore_pch_deps = value;
      break;

    case OPT_fpch_preprocess:
      flag_pch_preprocess = value;
      break;

    case OPT_fpermissive:
      flag_permissive = value;
      break;

    case OPT_fpreprocessed:
      cpp_opts->preprocessed = value;
      break;

    case OPT_freplace_objc_classes:
      flag_replace_objc_classes = value;
      break;

    case OPT_frepo:
      flag_use_repository = value;
      if (value)
	flag_implicit_templates = 0;
      break;

    case OPT_frtti:
      flag_rtti = value;
      break;

    case OPT_fshow_column:
      cpp_opts->show_column = value;
      break;

    case OPT_fstats:
      flag_detailed_statistics = value;
      break;

    case OPT_ftabstop_:
      /* It is documented that we silently ignore silly values.  */
      if (value >= 1 && value <= 100)
	cpp_opts->tabstop = value;
      break;

    case OPT_fexec_charset_:
      cpp_opts->narrow_charset = arg;
      break;

    case OPT_fwide_exec_charset_:
      cpp_opts->wide_charset = arg;
      break;

    case OPT_finput_charset_:
      cpp_opts->input_charset = arg;
      break;

    case OPT_ftemplate_depth_:
      max_tinst_depth = value;
      break;

    case OPT_fuse_cxa_atexit:
      flag_use_cxa_atexit = value;
      break;
      
    case OPT_fuse_cxa_get_exception_ptr:
      flag_use_cxa_get_exception_ptr = value;
      break;

    case OPT_fvisibility_inlines_hidden:
      visibility_options.inlines_hidden = value;
      break;

    case OPT_fweak:
      flag_weak = value;
      break;

    case OPT_fthreadsafe_statics:
      flag_threadsafe_statics = value;
      break;

    case OPT_fzero_link:
      flag_zero_link = value;
      break;

    case OPT_gen_decls:
      flag_gen_declaration = 1;
      break;

    case OPT_femit_struct_debug_baseonly:
      set_struct_debug_option ("base");
      break;

    case OPT_femit_struct_debug_reduced:
      set_struct_debug_option ("dir:ord:sys,dir:gen:any,ind:base");
      break;

    case OPT_femit_struct_debug_detailed_:
      set_struct_debug_option (arg);
      break;

    case OPT_idirafter:
      add_path (xstrdup (arg), AFTER, 0, true);
      break;

    case OPT_imacros:
    case OPT_include:
      defer_opt (code, arg);
      break;

    case OPT_imultilib:
      imultilib = arg;
      break;

    case OPT_iprefix:
      iprefix = arg;
      break;

    case OPT_iquote:
      add_path (xstrdup (arg), QUOTE, 0, true);
      break;

    case OPT_isysroot:
      sysroot = arg;
      break;

    case OPT_isystem:
      add_path (xstrdup (arg), SYSTEM, 0, true);
      break;

    case OPT_iwithprefix:
      add_prefixed_path (arg, SYSTEM);
      break;

    case OPT_iwithprefixbefore:
      add_prefixed_path (arg, BRACKET);
      break;

    case OPT_lang_asm:
      cpp_set_lang (parse_in, CLK_ASM);
      cpp_opts->dollars_in_ident = false;
      break;

    case OPT_lang_fortran:
      lang_fortran = true;
      break;

    case OPT_lang_objc:
      cpp_opts->objc = 1;
      break;

    case OPT_nostdinc:
      std_inc = false;
      break;

    case OPT_nostdinc__:
      std_cxx_inc = false;
      break;

    case OPT_o:
      if (!out_fname)
	out_fname = arg;
      else
	error ("output filename specified twice");
      break;

      /* We need to handle the -pedantic switches here, rather than in
	 c_common_post_options, so that a subsequent -Wno-endif-labels
	 is not overridden.  */
    case OPT_pedantic_errors:
      cpp_opts->pedantic_errors = 1;
      /* Fall through.  */
    case OPT_pedantic:
      cpp_opts->pedantic = 1;
      cpp_opts->warn_endif_labels = 1;
      if (warn_pointer_sign == -1)
	warn_pointer_sign = 1;
      if (warn_overlength_strings == -1)
	warn_overlength_strings = 1;
      break;

    case OPT_print_objc_runtime_info:
      print_struct_values = 1;
      break;

    case OPT_print_pch_checksum:
      c_common_print_pch_checksum (stdout);
      exit_after_options = true;
      break;

    case OPT_remap:
      cpp_opts->remap = 1;
      break;

    case OPT_std_c__98:
    case OPT_std_gnu__98:
      if (!preprocessing_asm_p)
	set_std_cxx98 (code == OPT_std_c__98 /* ISO */);
      break;

    case OPT_std_c89:
    case OPT_std_iso9899_1990:
    case OPT_std_iso9899_199409:
      if (!preprocessing_asm_p)
	set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */);
      break;

    case OPT_std_gnu89:
      if (!preprocessing_asm_p)
	set_std_c89 (false /* c94 */, false /* ISO */);
      break;

    case OPT_std_c99:
    case OPT_std_c9x:
    case OPT_std_iso9899_1999:
    case OPT_std_iso9899_199x:
      if (!preprocessing_asm_p)
	set_std_c99 (true /* ISO */);
      break;

    case OPT_std_gnu99:
    case OPT_std_gnu9x:
      if (!preprocessing_asm_p)
	set_std_c99 (false /* ISO */);
      break;

    case OPT_trigraphs:
      cpp_opts->trigraphs = 1;
      break;

    case OPT_traditional_cpp:
      cpp_opts->traditional = 1;
      break;

    case OPT_undef:
      flag_undef = 1;
      break;

    case OPT_w:
      cpp_opts->inhibit_warnings = 1;
      break;

    case OPT_v:
      verbose = true;
      break;
    }

  return result;
}
Exemple #15
0
/* Handle switch SCODE with argument ARG.  VALUE is true, unless no-
   form of an -f or -W option was given.  Returns false if the switch was
   invalid, true if valid.  Use HANDLERS in recursive handle_option calls.  */
bool
c_common_handle_option (size_t scode, const char *arg, int value,
			int kind, location_t loc,
			const struct cl_option_handlers *handlers)
{
  const struct cl_option *option = &cl_options[scode];
  enum opt_code code = (enum opt_code) scode;
  bool result = true;

  /* Prevent resetting the language standard to a C dialect when the driver
     has already determined that we're looking at assembler input.  */
  bool preprocessing_asm_p = (cpp_get_options (parse_in)->lang == CLK_ASM);

  switch (code)
    {
    default:
      if (cl_options[code].flags & c_family_lang_mask)
	{
	  if ((option->flags & CL_TARGET)
	      && ! targetcm.handle_c_option (scode, arg, value))
	    result = false;
	  break;
	}
      result = false;
      break;

    case OPT__output_pch_:
      pch_file = arg;
      break;

    case OPT_A:
      defer_opt (code, arg);
      break;

    case OPT_C:
      cpp_opts->discard_comments = 0;
      break;

    case OPT_CC:
      cpp_opts->discard_comments = 0;
      cpp_opts->discard_comments_in_macro_exp = 0;
      break;

    case OPT_D:
      defer_opt (code, arg);
      break;

    case OPT_H:
      cpp_opts->print_include_names = 1;
      break;

    case OPT_F:
      TARGET_OPTF (xstrdup (arg));
      break;

    case OPT_I:
      if (strcmp (arg, "-"))
	add_path (xstrdup (arg), BRACKET, 0, true);
      else
	{
	  if (quote_chain_split)
	    error ("-I- specified twice");
	  quote_chain_split = true;
	  split_quote_chain ();
	  inform (input_location, "obsolete option -I- used, please use -iquote instead");
	}
      break;

    case OPT_M:
    case OPT_MM:
      /* When doing dependencies with -M or -MM, suppress normal
	 preprocessed output, but still do -dM etc. as software
	 depends on this.  Preprocessed output does occur if -MD, -MMD
	 or environment var dependency generation is used.  */
      cpp_opts->deps.style = (code == OPT_M ? DEPS_SYSTEM: DEPS_USER);
      flag_no_output = 1;
      break;

    case OPT_MD:
    case OPT_MMD:
      cpp_opts->deps.style = (code == OPT_MD ? DEPS_SYSTEM: DEPS_USER);
      cpp_opts->deps.need_preprocessor_output = true;
      deps_file = arg;
      break;

    case OPT_MF:
      deps_seen = true;
      deps_file = arg;
      break;

    case OPT_MG:
      deps_seen = true;
      cpp_opts->deps.missing_files = true;
      break;

    case OPT_MP:
      deps_seen = true;
      cpp_opts->deps.phony_targets = true;
      break;

    case OPT_MQ:
    case OPT_MT:
      deps_seen = true;
      defer_opt (code, arg);
      break;

    case OPT_P:
      flag_no_line_commands = 1;
      break;

    case OPT_U:
      defer_opt (code, arg);
      break;

    case OPT_Wall:
      /* ??? Don't add new options here. Use LangEnabledBy in c.opt.  */

      cpp_opts->warn_trigraphs = value;
      cpp_opts->warn_comments = value;
      cpp_opts->warn_num_sign_change = value;
      break;

    case OPT_Wbuiltin_macro_redefined:
      cpp_opts->warn_builtin_macro_redefined = value;
      break;

    case OPT_Wcomment:
      cpp_opts->warn_comments = value;
      break;

    case OPT_Wc___compat:
      cpp_opts->warn_cxx_operator_names = value;
      break;

    case OPT_Wdeprecated:
      cpp_opts->cpp_warn_deprecated = value;
      break;

    case OPT_Wendif_labels:
      cpp_opts->warn_endif_labels = value;
      break;

    case OPT_Winvalid_pch:
      cpp_opts->warn_invalid_pch = value;
      break;

    case OPT_Wliteral_suffix:
      cpp_opts->warn_literal_suffix = value;
      break;

    case OPT_Wlong_long:
      cpp_opts->cpp_warn_long_long = value;
      break;

    case OPT_Wmissing_include_dirs:
      cpp_opts->warn_missing_include_dirs = value;
      break;

    case OPT_Wmultichar:
      cpp_opts->warn_multichar = value;
      break;

    case OPT_Wnormalized_:
      if (kind == DK_ERROR)
	{
	  gcc_assert (!arg);
	  inform (input_location, "-Werror=normalized=: set -Wnormalized=nfc");
	  cpp_opts->warn_normalize = normalized_C;
	}
      else
	{
	  if (!value || (arg && strcasecmp (arg, "none") == 0))
	    cpp_opts->warn_normalize = normalized_none;
	  else if (!arg || strcasecmp (arg, "nfkc") == 0)
	    cpp_opts->warn_normalize = normalized_KC;
	  else if (strcasecmp (arg, "id") == 0)
	    cpp_opts->warn_normalize = normalized_identifier_C;
	  else if (strcasecmp (arg, "nfc") == 0)
	    cpp_opts->warn_normalize = normalized_C;
	  else
	    error ("argument %qs to %<-Wnormalized%> not recognized", arg);
	  break;
	}

    case OPT_Wtraditional:
      cpp_opts->cpp_warn_traditional = value;
      break;

    case OPT_Wtrigraphs:
      cpp_opts->warn_trigraphs = value;
      break;

    case OPT_Wundef:
      cpp_opts->warn_undef = value;
      break;

    case OPT_Wunknown_pragmas:
      /* Set to greater than 1, so that even unknown pragmas in
	 system headers will be warned about.  */
      /* ??? There is no way to handle this automatically for now.  */
      warn_unknown_pragmas = value * 2;
      break;

    case OPT_ansi:
      if (!c_dialect_cxx ())
	set_std_c89 (false, true);
      else
	set_std_cxx98 (true);
      break;

    case OPT_d:
      handle_OPT_d (arg);
      break;

    case OPT_fcanonical_system_headers:
      cpp_opts->canonical_system_headers = value;
      break;

    case OPT_fcond_mismatch:
      if (!c_dialect_cxx ())
	{
	  flag_cond_mismatch = value;
	  break;
	}
      warning (0, "switch %qs is no longer supported", option->opt_text);
      break;

    case OPT_fbuiltin_:
      if (value)
	result = false;
      else
	disable_builtin_function (arg);
      break;

    case OPT_fdirectives_only:
      cpp_opts->directives_only = value;
      break;

    case OPT_fdollars_in_identifiers:
      cpp_opts->dollars_in_ident = value;
      break;

    case OPT_ffreestanding:
      value = !value;
      /* Fall through....  */
    case OPT_fhosted:
      flag_hosted = value;
      flag_no_builtin = !value;
      break;

    case OPT_fconstant_string_class_:
      constant_string_class_name = arg;
      break;

    case OPT_fextended_identifiers:
      cpp_opts->extended_identifiers = value;
      break;

    case OPT_foperator_names:
      cpp_opts->operator_names = value;
      break;

    case OPT_fpch_deps:
      cpp_opts->restore_pch_deps = value;
      break;

    case OPT_fpch_preprocess:
      flag_pch_preprocess = value;
      break;

    case OPT_fpermissive:
      flag_permissive = value;
      global_dc->permissive = value;
      break;

    case OPT_fpreprocessed:
      cpp_opts->preprocessed = value;
      break;

    case OPT_fdebug_cpp:
      cpp_opts->debug = 1;
      break;

    case OPT_ftrack_macro_expansion:
      if (value)
	value = 2;
      /* Fall Through.  */

    case OPT_ftrack_macro_expansion_:
      if (arg && *arg != '\0')
	cpp_opts->track_macro_expansion = value;
      else
	cpp_opts->track_macro_expansion = 2;
      break;

    case OPT_frepo:
      flag_use_repository = value;
      if (value)
	flag_implicit_templates = 0;
      break;

    case OPT_ftabstop_:
      /* It is documented that we silently ignore silly values.  */
      if (value >= 1 && value <= 100)
	cpp_opts->tabstop = value;
      break;

    case OPT_fexec_charset_:
      cpp_opts->narrow_charset = arg;
      break;

    case OPT_fwide_exec_charset_:
      cpp_opts->wide_charset = arg;
      break;

    case OPT_finput_charset_:
      cpp_opts->input_charset = arg;
      break;

    case OPT_ftemplate_depth_:
      max_tinst_depth = value;
      break;

    case OPT_fvisibility_inlines_hidden:
      visibility_options.inlines_hidden = value;
      break;

    case OPT_femit_struct_debug_baseonly:
      set_struct_debug_option (&global_options, loc, "base");
      break;

    case OPT_femit_struct_debug_reduced:
      set_struct_debug_option (&global_options, loc,
			       "dir:ord:sys,dir:gen:any,ind:base");
      break;

    case OPT_femit_struct_debug_detailed_:
      set_struct_debug_option (&global_options, loc, arg);
      break;

    case OPT_fext_numeric_literals:
      cpp_opts->ext_numeric_literals = value;
      break;

    case OPT_idirafter:
      add_path (xstrdup (arg), AFTER, 0, true);
      break;

    case OPT_imacros:
    case OPT_include:
      defer_opt (code, arg);
      break;

    case OPT_imultilib:
      imultilib = arg;
      break;

    case OPT_iprefix:
      iprefix = arg;
      break;

    case OPT_iquote:
      add_path (xstrdup (arg), QUOTE, 0, true);
      break;

    case OPT_isysroot:
      sysroot = arg;
      break;

    case OPT_isystem:
      add_path (xstrdup (arg), SYSTEM, 0, true);
      break;

    case OPT_iwithprefix:
      add_prefixed_path (arg, SYSTEM);
      break;

    case OPT_iwithprefixbefore:
      add_prefixed_path (arg, BRACKET);
      break;

    case OPT_lang_asm:
      cpp_set_lang (parse_in, CLK_ASM);
      cpp_opts->dollars_in_ident = false;
      break;

    case OPT_nostdinc:
      std_inc = false;
      break;

    case OPT_nostdinc__:
      std_cxx_inc = false;
      break;

    case OPT_o:
      if (!out_fname)
	out_fname = arg;
      else
	error ("output filename specified twice");
      break;

      /* We need to handle the -Wpedantic switch here, rather than in
	 c_common_post_options, so that a subsequent -Wno-endif-labels
	 is not overridden.  */
    case OPT_Wpedantic:
      cpp_opts->cpp_pedantic = 1;
      cpp_opts->warn_endif_labels = 1;
      break;

    case OPT_print_objc_runtime_info:
      print_struct_values = 1;
      break;

    case OPT_remap:
      cpp_opts->remap = 1;
      break;

    case OPT_std_c__98:
    case OPT_std_gnu__98:
      if (!preprocessing_asm_p)
	set_std_cxx98 (code == OPT_std_c__98 /* ISO */);
      break;

    case OPT_std_c__11:
    case OPT_std_gnu__11:
      if (!preprocessing_asm_p)
	{
	  set_std_cxx11 (code == OPT_std_c__11 /* ISO */);
	  if (code == OPT_std_c__11)
	    cpp_opts->ext_numeric_literals = 0;
	}
      break;

    case OPT_std_c__1y:
    case OPT_std_gnu__1y:
      if (!preprocessing_asm_p)
	{
	  set_std_cxx1y (code == OPT_std_c__1y /* ISO */);
	  if (code == OPT_std_c__1y)
	    cpp_opts->ext_numeric_literals = 0;
	}
      break;

    case OPT_std_c90:
    case OPT_std_iso9899_199409:
      if (!preprocessing_asm_p)
	set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */);
      break;

    case OPT_std_gnu90:
      if (!preprocessing_asm_p)
	set_std_c89 (false /* c94 */, false /* ISO */);
      break;

    case OPT_std_c99:
      if (!preprocessing_asm_p)
	set_std_c99 (true /* ISO */);
      break;

    case OPT_std_gnu99:
      if (!preprocessing_asm_p)
	set_std_c99 (false /* ISO */);
      break;

    case OPT_std_c11:
      if (!preprocessing_asm_p)
	set_std_c11 (true /* ISO */);
      break;

    case OPT_std_gnu11:
      if (!preprocessing_asm_p)
	set_std_c11 (false /* ISO */);
      break;

    case OPT_trigraphs:
      cpp_opts->trigraphs = 1;
      break;

    case OPT_traditional_cpp:
      cpp_opts->traditional = 1;
      break;

    case OPT_v:
      verbose = true;
      break;

    case OPT_Wabi:
      warn_psabi = value;
      break;
    }

  switch (c_language)
    {
    case clk_c:
      C_handle_option_auto (&global_options, &global_options_set, 
                            scode, arg, value, 
                            c_family_lang_mask, kind,
                            loc, handlers, global_dc);
      break;

    case clk_objc:
      ObjC_handle_option_auto (&global_options, &global_options_set,
                               scode, arg, value, 
                               c_family_lang_mask, kind,
                               loc, handlers, global_dc);
      break;

    case clk_cxx:
      CXX_handle_option_auto (&global_options, &global_options_set,
                              scode, arg, value,
                              c_family_lang_mask, kind,
                              loc, handlers, global_dc);
      break;

    case clk_objcxx:
      ObjCXX_handle_option_auto (&global_options, &global_options_set,
                                 scode, arg, value,
                                 c_family_lang_mask, kind,
                                 loc, handlers, global_dc);
      break;

    default:
      gcc_unreachable ();
    }
  
  return result;
}
Exemple #16
0
/* Hook that registers front end and target-specific built-ins.  */
void
c_cpp_builtins (cpp_reader *pfile)
{
  /* -undef turns off target-specific built-ins.  */
  if (flag_undef)
    return;

  define__GNUC__ ();

  /* For stddef.h.  They require macros defined in c-common.c.  */
  c_stddef_cpp_builtins ();

  if (c_dialect_cxx ())
    {
      if (SUPPORTS_ONE_ONLY)
	cpp_define (pfile, "__GXX_WEAK__=1");
      else
	cpp_define (pfile, "__GXX_WEAK__=0");
      if (warn_deprecated)
	cpp_define (pfile, "__DEPRECATED");
    }
  /* Note that we define this for C as well, so that we know if
     __attribute__((cleanup)) will interface with EH.  */
  if (flag_exceptions)
    cpp_define (pfile, "__EXCEPTIONS");

  /* Represents the C++ ABI version, always defined so it can be used while
     preprocessing C and assembler.  */
  if (flag_abi_version == 0)
    /* Use a very large value so that:

         #if __GXX_ABI_VERSION >= <value for version X>

       will work whether the user explicitly says "-fabi-version=x" or
       "-fabi-version=0".  Do not use INT_MAX because that will be
       different from system to system.  */
    builtin_define_with_int_value ("__GXX_ABI_VERSION", 999999);
  else if (flag_abi_version == 1)
    /* Due to an historical accident, this version had the value
       "102".  */
    builtin_define_with_int_value ("__GXX_ABI_VERSION", 102);
  else
    /* Newer versions have values 1002, 1003, ....  */
    builtin_define_with_int_value ("__GXX_ABI_VERSION", 
				   1000 + flag_abi_version);

  /* libgcc needs to know this.  */
  if (USING_SJLJ_EXCEPTIONS)
    cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__");

  /* limits.h needs to know these.  */
  builtin_define_type_max ("__SCHAR_MAX__", signed_char_type_node, 0);
  builtin_define_type_max ("__SHRT_MAX__", short_integer_type_node, 0);
  builtin_define_type_max ("__INT_MAX__", integer_type_node, 0);
  builtin_define_type_max ("__LONG_MAX__", long_integer_type_node, 1);
  builtin_define_type_max ("__LONG_LONG_MAX__", long_long_integer_type_node, 2);
  builtin_define_type_max ("__WCHAR_MAX__", wchar_type_node, 0);

  builtin_define_type_precision ("__CHAR_BIT__", char_type_node);

  /* float.h needs to know these.  */

  builtin_define_with_int_value ("__FLT_EVAL_METHOD__",
				 TARGET_FLT_EVAL_METHOD);

  builtin_define_float_constants ("FLT", "F", float_type_node);
  builtin_define_float_constants ("DBL", "", double_type_node);
  builtin_define_float_constants ("LDBL", "L", long_double_type_node);

  /* For use in assembly language.  */
  builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
  builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);

  /* Misc.  */
  builtin_define_with_value ("__VERSION__", version_string, 1);

  /* Definitions for LP64 model.  */
  if (TYPE_PRECISION (long_integer_type_node) == 64
      && POINTER_SIZE == 64
      && TYPE_PRECISION (integer_type_node) == 32)
    {
      cpp_define (pfile, "_LP64");
      cpp_define (pfile, "__LP64__");
    }

  /* Other target-independent built-ins determined by command-line
     options.  */
  if (optimize_size)
    cpp_define (pfile, "__OPTIMIZE_SIZE__");
  if (optimize)
    cpp_define (pfile, "__OPTIMIZE__");

  if (fast_math_flags_set_p ())
    cpp_define (pfile, "__FAST_MATH__");
  if (flag_really_no_inline)
    cpp_define (pfile, "__NO_INLINE__");
  if (flag_signaling_nans)
    cpp_define (pfile, "__SUPPORT_SNAN__");
  if (flag_finite_math_only)
    cpp_define (pfile, "__FINITE_MATH_ONLY__=1");
  else
    cpp_define (pfile, "__FINITE_MATH_ONLY__=0");

  if (flag_iso)
    cpp_define (pfile, "__STRICT_ANSI__");

  if (!flag_signed_char)
    cpp_define (pfile, "__CHAR_UNSIGNED__");

  if (c_dialect_cxx () && TREE_UNSIGNED (wchar_type_node))
    cpp_define (pfile, "__WCHAR_UNSIGNED__");

  /* Make the choice of ObjC runtime visible to source code.  */
  if (c_dialect_objc () && flag_next_runtime)
    cpp_define (pfile, "__NEXT_RUNTIME__");

  /* A straightforward target hook doesn't work, because of problems
     linking that hook's body when part of non-C front ends.  */
# define preprocessing_asm_p() (cpp_get_options (pfile)->lang == CLK_ASM)
# define preprocessing_trad_p() (cpp_get_options (pfile)->traditional)
# define builtin_define(TXT) cpp_define (pfile, TXT)
# define builtin_assert(TXT) cpp_assert (pfile, TXT)
  TARGET_CPU_CPP_BUILTINS ();
  TARGET_OS_CPP_BUILTINS ();
  TARGET_OBJFMT_CPP_BUILTINS ();
}
Exemple #17
0
/* Define __GNUC__, __GNUC_MINOR__ and __GNUC_PATCHLEVEL__.  */
static void
define__GNUC__ (void)
{
  /* The format of the version string, enforced below, is
     ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)?  */
  const char *q, *v = version_string;

  while (*v && !ISDIGIT (*v))
    v++;
  gcc_assert (*v && (v <= version_string || v[-1] == '-'));

  q = v;
  while (ISDIGIT (*v))
    v++;
  builtin_define_with_value_n ("__GNUC__", q, v - q);
  if (c_dialect_cxx ())
    builtin_define_with_value_n ("__GNUG__", q, v - q);

  gcc_assert (*v == '.' && ISDIGIT (v[1]));

  q = ++v;
  while (ISDIGIT (*v))
    v++;
  builtin_define_with_value_n ("__GNUC_MINOR__", q, v - q);

  if (*v == '.')
    {
      gcc_assert (ISDIGIT (v[1]));
      q = ++v;
      while (ISDIGIT (*v))
	v++;
      builtin_define_with_value_n ("__GNUC_PATCHLEVEL__", q, v - q);
    }
  else
    builtin_define_with_value_n ("__GNUC_PATCHLEVEL__", "0", 1);

  gcc_assert (!*v || *v == ' ' || *v == '-');

  /* LLVM LOCAL no version number */
#ifdef CONFIG_DARWIN_H
#ifndef LLVM_VERSION_INFO

  /* APPLE LOCAL begin Apple version */
  {
    /* This chunk of code defines __APPLE_CC__ from the version
       string.  It expects to see a substring of the version string of
       the form "build NNNN)", where each N is a digit, and the first
       N is nonzero (there can be 4 or 5 digits).  It will abort() if
       these conditions are not met, since that usually means that
       someone's broken the version string.  */
    const char *vt;
    
    vt = strstr (version_string, "build ");
    if (vt == NULL)
      abort ();
    vt += strlen ("build ");
    if (! ISDIGIT (*vt))
      abort ();
    for (q = vt; *q != 0 && ISDIGIT (*q); q++)
      ;
    if (q == vt || *q != ')')
      abort ();
    if ((q - vt != 4 && q - vt != 5) || *vt == '0')
      abort ();
    builtin_define_with_value_n ("__APPLE_CC__", vt, q - vt);
  }
  /* APPLE LOCAL end Apple version */

  /* LLVM LOCAL begin version number */
#else
  /* This chunk of code defines __APPLE_CC__ from the version
     string.  It expects to see a substring of the version string of
     the form "build NNNN)", where each N is a digit, and the first
     N is nonzero (there can be 4 or 5 digits).  It will abort() if
     these conditions are not met, since that usually means that
     someone's broken the version string.  */

  /* LLVM builds multiple different ways.  For example, for official releases,
     the version number is something like "1.8".  We don't want to disable
     __APPLE_CC__ entirely, as this breaks system headers.  If the build number
     is not a 4-digit code, just define __APPLE_CC__ to 1 instead of abort()ing
     as per above comment.
   */
  {
    const char *vt;

    vt = strstr (version_string, "build ");
    if (vt == NULL) {
      builtin_define_with_value_n ("__APPLE_CC__", "1", 1);
      return;
    }

    vt += strlen ("build ");
    if (! ISDIGIT (*vt)) {
      builtin_define_with_value_n ("__APPLE_CC__", "1", 1);
      return;
    }
    for (q = vt; *q != 0 && ISDIGIT (*q); q++)
      ;
    if (q == vt || *q != ')') {
      builtin_define_with_value_n ("__APPLE_CC__", "1", 1);
      return;
    }

    if ((q - vt != 4 && q - vt != 5) || *vt == '0')
      builtin_define_with_value_n ("__APPLE_CC__", "1", 1);
    else
      builtin_define_with_value_n ("__APPLE_CC__", vt, q - vt);
  }
#endif /*LLVM_VERSION_INFO*/
#endif /*CONFIG_DARWIN_H*/
  /* LLVM LOCAL end version number */
}
Exemple #18
0
void gcc_plugin_finish_decl(void *gcc_data, void *user_data)
{
    tree decl = (tree) gcc_data;
    tree type = TREE_TYPE(decl);

    // push this onto the pending parameters if necessary.
    if (TREE_CODE(decl) == PARM_DECL) {
        // we should only see parameter declarations for C.
        gcc_assert(!c_dialect_cxx());

        struct XIL_ParamDecl *last = xil_pending_param_decls;
        while (last && last->next) last = last->next;

        struct XIL_ParamDecl *param_decl = xcalloc(1, sizeof(struct XIL_ParamDecl));
        param_decl->decl = decl;
        if (last) last->next = param_decl;
        else xil_pending_param_decls = param_decl;

        return;
    }

    // check for typedefs on structures, and assign the structure a name
    // if one is found.
    if (TREE_CODE(decl) == TYPE_DECL &&
            (TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE)) {
        if (XIL_IsAnonymous(type)) {
            const char *name = IDENTIFIER_POINTER(DECL_NAME(decl));
            XIL_CSUName(type, name);
        }
    }

    // check for a global variable.
    bool is_global = false;

    if (TREE_CODE(decl) == VAR_DECL) {
        if (DECL_CONTEXT(decl) == NULL)
            is_global = true;
        if (TREE_STATIC(decl))
            is_global = true;
    }

    bool is_function = (TREE_CODE(decl) == FUNCTION_DECL);

    if (!is_global && !is_function)
        return;

    // only processing the output function for annotations.
    if (xil_has_annotation)
        return;

    XIL_Var var = XIL_TranslateVar(decl);
    const char *name = XIL_GetVarName(var);

    // future parameter declarations will be for a different function.
    xil_pending_param_decls = NULL;

    if (!is_global)
        return;

    // check if this is a global variable we want to skip. these are introduced
    // for type information globals.
    static const char *bad_prefix_list[] = {
        "const __class_type_info_pseudo",
        "const __si_class_type_info_pseudo",
        "const __vmi_class_type_info_pseudo",
        "const char _ZTS",
        NULL
    };
    int ind;
    for (ind = 0; bad_prefix_list[ind]; ind++) {
        const char *bad_prefix = bad_prefix_list[ind];
        if (!strncmp(name, bad_prefix, strlen(bad_prefix)))
            return;
    }

    // if the decl is contained in a template class then skip it. we can only
    // handle instantiated declarations, and will only see the uninstantiated
    // declarations here. TODO: is there a way to get these?
    if (DECL_LANG_SPECIFIC(decl) != NULL &&
            DECL_TEMPLATE_INFO(decl) != NULL)
        return;
    tree context = DECL_CONTEXT(decl);
    while (context && TREE_CODE(context) == FUNCTION_DECL) {
        if (DECL_LANG_SPECIFIC(context) != NULL &&
                DECL_TEMPLATE_INFO(context) != NULL)
            return;
        context = DECL_CONTEXT(context);
    }

    // this is a function or global, process any annotation attributes.
    tree attr = DECL_ATTRIBUTES(decl);
    while (attr) {
        XIL_ProcessAnnotationAttr(decl, attr, NULL, NULL);
        attr = TREE_CHAIN(attr);
    }

    // also look for annotations read in from file.
    for (ind = 0; ind < XIL_GetAnnotationCount(name, !is_function, false); ind++) {
        const char *where;
        const char *point_text, *annot_text;
        int trusted;
        XIL_GetAnnotation(name, !is_function, false, ind, &where,
                          &point_text, &annot_text, &trusted);

        // we'll handle loop invariants and point assertions after seeing the
        // function's definition.
        if (!strncmp(where, "loop", 4) || point_text)
            continue;

        XIL_ProcessAnnotationRead(decl, where, point_text, annot_text, trusted);
    }

    XIL_GenerateBlock(decl);
}
Exemple #19
0
/* Hook that registers front end and target-specific built-ins.  */
void
c_cpp_builtins (cpp_reader *pfile)
{
  /* -undef turns off target-specific built-ins.  */
  if (flag_undef)
    return;

  define__GNUC__ ();

  /* For stddef.h.  They require macros defined in c-common.c.  */
  c_stddef_cpp_builtins ();

  if (c_dialect_cxx ())
    {
      if (flag_weak && SUPPORTS_ONE_ONLY)
	cpp_define (pfile, "__GXX_WEAK__=1");
      else
	cpp_define (pfile, "__GXX_WEAK__=0");
      if (warn_deprecated)
	cpp_define (pfile, "__DEPRECATED");
    }
  /* Note that we define this for C as well, so that we know if
     __attribute__((cleanup)) will interface with EH.  */
  if (flag_exceptions)
    cpp_define (pfile, "__EXCEPTIONS");

  /* Represents the C++ ABI version, always defined so it can be used while
     preprocessing C and assembler.  */
  if (flag_abi_version == 0)
    /* Use a very large value so that:

	 #if __GXX_ABI_VERSION >= <value for version X>

       will work whether the user explicitly says "-fabi-version=x" or
       "-fabi-version=0".  Do not use INT_MAX because that will be
       different from system to system.  */
    builtin_define_with_int_value ("__GXX_ABI_VERSION", 999999);
  else if (flag_abi_version == 1)
    /* Due to a historical accident, this version had the value
       "102".  */
    builtin_define_with_int_value ("__GXX_ABI_VERSION", 102);
  else
    /* Newer versions have values 1002, 1003, ....  */
    builtin_define_with_int_value ("__GXX_ABI_VERSION",
				   1000 + flag_abi_version);

  /* libgcc needs to know this.  */
  if (USING_SJLJ_EXCEPTIONS)
    cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__");

  /* limits.h needs to know these.  */
  builtin_define_type_max ("__SCHAR_MAX__", signed_char_type_node, 0);
  builtin_define_type_max ("__SHRT_MAX__", short_integer_type_node, 0);
  builtin_define_type_max ("__INT_MAX__", integer_type_node, 0);
  builtin_define_type_max ("__LONG_MAX__", long_integer_type_node, 1);
  builtin_define_type_max ("__LONG_LONG_MAX__", long_long_integer_type_node, 2);
  builtin_define_type_max ("__WCHAR_MAX__", wchar_type_node, 0);

  builtin_define_type_precision ("__CHAR_BIT__", char_type_node);

  /* stdint.h (eventually) and the testsuite need to know these.  */
  builtin_define_stdint_macros ();

  /* float.h needs to know these.  */

  builtin_define_with_int_value ("__FLT_EVAL_METHOD__",
				 TARGET_FLT_EVAL_METHOD);

  /* And decfloat.h needs this.  */
  builtin_define_with_int_value ("__DEC_EVAL_METHOD__",
                                 TARGET_DEC_EVAL_METHOD);

  builtin_define_float_constants ("FLT", "F", "%s", float_type_node);
  /* Cast the double precision constants when single precision constants are
     specified. The correct result is computed by the compiler when using 
     macros that include a cast. This has the side-effect of making the value 
     unusable in const expressions. */
  if (flag_single_precision_constant)
    builtin_define_float_constants ("DBL", "L", "((double)%s)", double_type_node);
  else
    builtin_define_float_constants ("DBL", "", "%s", double_type_node);
  builtin_define_float_constants ("LDBL", "L", "%s", long_double_type_node);

  /* For decfloat.h.  */
  builtin_define_decimal_float_constants ("DEC32", "DF", dfloat32_type_node);
  builtin_define_decimal_float_constants ("DEC64", "DD", dfloat64_type_node);
  builtin_define_decimal_float_constants ("DEC128", "DL", dfloat128_type_node);

  /* For use in assembly language.  */
  builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
  builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);

  /* Misc.  */
  builtin_define_with_value ("__VERSION__", version_string, 1);

  cpp_define (pfile, "__GNUC_GNU_INLINE__");

  /* Definitions for LP64 model.  */
  if (TYPE_PRECISION (long_integer_type_node) == 64
      && POINTER_SIZE == 64
      && TYPE_PRECISION (integer_type_node) == 32)
    {
      cpp_define (pfile, "_LP64");
      cpp_define (pfile, "__LP64__");
    }

  /* Other target-independent built-ins determined by command-line
     options.  */
  if (optimize_size)
    cpp_define (pfile, "__OPTIMIZE_SIZE__");
  if (optimize)
    cpp_define (pfile, "__OPTIMIZE__");

  if (fast_math_flags_set_p ())
    cpp_define (pfile, "__FAST_MATH__");
  if (flag_really_no_inline)
    cpp_define (pfile, "__NO_INLINE__");
  if (flag_signaling_nans)
    cpp_define (pfile, "__SUPPORT_SNAN__");
  if (flag_finite_math_only)
    cpp_define (pfile, "__FINITE_MATH_ONLY__=1");
  else
    cpp_define (pfile, "__FINITE_MATH_ONLY__=0");
  if (flag_pic)
    {
      builtin_define_with_int_value ("__pic__", flag_pic);
      builtin_define_with_int_value ("__PIC__", flag_pic);
    }

  if (flag_iso)
    cpp_define (pfile, "__STRICT_ANSI__");

  if (!flag_signed_char)
    cpp_define (pfile, "__CHAR_UNSIGNED__");

  if (c_dialect_cxx () && TYPE_UNSIGNED (wchar_type_node))
    cpp_define (pfile, "__WCHAR_UNSIGNED__");

  /* Make the choice of ObjC runtime visible to source code.  */
  if (c_dialect_objc () && flag_next_runtime)
    cpp_define (pfile, "__NEXT_RUNTIME__");

  /* Show the availability of some target pragmas.  */
  if (flag_mudflap || targetm.handle_pragma_redefine_extname)
    cpp_define (pfile, "__PRAGMA_REDEFINE_EXTNAME");

  if (targetm.handle_pragma_extern_prefix)
    cpp_define (pfile, "__PRAGMA_EXTERN_PREFIX");

  /* Make the choice of the stack protector runtime visible to source code.
     The macro names and values here were chosen for compatibility with an
     earlier implementation, i.e. ProPolice.  */
  if (flag_stack_protect == 2)
    cpp_define (pfile, "__SSP_ALL__=2");
  else if (flag_stack_protect == 1)
    cpp_define (pfile, "__SSP__=1");

  if (flag_openmp)
    cpp_define (pfile, "_OPENMP=200505");

  /* A straightforward target hook doesn't work, because of problems
     linking that hook's body when part of non-C front ends.  */
# define preprocessing_asm_p() (cpp_get_options (pfile)->lang == CLK_ASM)
# define preprocessing_trad_p() (cpp_get_options (pfile)->traditional)
# define builtin_define(TXT) cpp_define (pfile, TXT)
# define builtin_assert(TXT) cpp_assert (pfile, TXT)
  TARGET_CPU_CPP_BUILTINS ();
  TARGET_OS_CPP_BUILTINS ();
  TARGET_OBJFMT_CPP_BUILTINS ();

  /* Support the __declspec keyword by turning them into attributes.
     Note that the current way we do this may result in a collision
     with predefined attributes later on.  This can be solved by using
     one attribute, say __declspec__, and passing args to it.  The
     problem with that approach is that args are not accumulated: each
     new appearance would clobber any existing args.  */
  if (TARGET_DECLSPEC)
    builtin_define ("__declspec(x)=__attribute__((x))");
}
/* Hook that registers front end and target-specific built-ins.  */
void
c_cpp_builtins (cpp_reader *pfile)
{
  /* -undef turns off target-specific built-ins.  */
  if (flag_undef)
    return;

  define__GNUC__ ();

  /* For stddef.h.  They require macros defined in c-common.c.  */
  c_stddef_cpp_builtins ();

  if (c_dialect_cxx ())
    {
      if (flag_weak && SUPPORTS_ONE_ONLY)
	cpp_define (pfile, "__GXX_WEAK__=1");
      else
	cpp_define (pfile, "__GXX_WEAK__=0");
      if (warn_deprecated)
	cpp_define (pfile, "__DEPRECATED");
      if (flag_rtti)
	cpp_define (pfile, "__GXX_RTTI");
      if (cxx_dialect == cxx0x)
        cpp_define (pfile, "__GXX_EXPERIMENTAL_CXX0X__");
    }
  /* Note that we define this for C as well, so that we know if
     __attribute__((cleanup)) will interface with EH.  */
  if (flag_exceptions)
    cpp_define (pfile, "__EXCEPTIONS");

  /* Represents the C++ ABI version, always defined so it can be used while
     preprocessing C and assembler.  */
  if (flag_abi_version == 0)
    /* Use a very large value so that:

	 #if __GXX_ABI_VERSION >= <value for version X>

       will work whether the user explicitly says "-fabi-version=x" or
       "-fabi-version=0".  Do not use INT_MAX because that will be
       different from system to system.  */
    builtin_define_with_int_value ("__GXX_ABI_VERSION", 999999);
  else if (flag_abi_version == 1)
    /* Due to a historical accident, this version had the value
       "102".  */
    builtin_define_with_int_value ("__GXX_ABI_VERSION", 102);
  else
    /* Newer versions have values 1002, 1003, ....  */
    builtin_define_with_int_value ("__GXX_ABI_VERSION",
				   1000 + flag_abi_version);

  /* libgcc needs to know this.  */
  if (USING_SJLJ_EXCEPTIONS)
    cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__");

  /* limits.h needs to know these.  */
  builtin_define_type_max ("__SCHAR_MAX__", signed_char_type_node, 0);
  builtin_define_type_max ("__SHRT_MAX__", short_integer_type_node, 0);
  builtin_define_type_max ("__INT_MAX__", integer_type_node, 0);
  builtin_define_type_max ("__LONG_MAX__", long_integer_type_node, 1);
  builtin_define_type_max ("__LONG_LONG_MAX__", long_long_integer_type_node, 2);
  builtin_define_type_max ("__WCHAR_MAX__", wchar_type_node, 0);

  builtin_define_type_precision ("__CHAR_BIT__", char_type_node);

  /* stdint.h (eventually) and the testsuite need to know these.  */
  builtin_define_stdint_macros ();

  /* float.h needs to know these.  */

  builtin_define_with_int_value ("__FLT_EVAL_METHOD__",
				 TARGET_FLT_EVAL_METHOD);

  /* And decfloat.h needs this.  */
  builtin_define_with_int_value ("__DEC_EVAL_METHOD__",
                                 TARGET_DEC_EVAL_METHOD);

  builtin_define_float_constants ("FLT", "F", "%s", float_type_node);
  /* Cast the double precision constants when single precision constants are
     specified. The correct result is computed by the compiler when using 
     macros that include a cast. This has the side-effect of making the value 
     unusable in const expressions. */
  if (flag_single_precision_constant)
    builtin_define_float_constants ("DBL", "L", "((double)%s)", double_type_node);
  else
    builtin_define_float_constants ("DBL", "", "%s", double_type_node);
  builtin_define_float_constants ("LDBL", "L", "%s", long_double_type_node);

  /* For decfloat.h.  */
  builtin_define_decimal_float_constants ("DEC32", "DF", dfloat32_type_node);
  builtin_define_decimal_float_constants ("DEC64", "DD", dfloat64_type_node);
  builtin_define_decimal_float_constants ("DEC128", "DL", dfloat128_type_node);

  /* For fixed-point fibt, ibit, max, min, and epsilon.  */
  if (targetm.fixed_point_supported_p ())
    {
      builtin_define_fixed_point_constants ("SFRACT", "HR",
					    short_fract_type_node);
      builtin_define_fixed_point_constants ("USFRACT", "UHR",
					    unsigned_short_fract_type_node);
      builtin_define_fixed_point_constants ("FRACT", "R",
					    fract_type_node);
      builtin_define_fixed_point_constants ("UFRACT", "UR",
					    unsigned_fract_type_node);
      builtin_define_fixed_point_constants ("LFRACT", "LR",
					    long_fract_type_node);
      builtin_define_fixed_point_constants ("ULFRACT", "ULR",
					    unsigned_long_fract_type_node);
      builtin_define_fixed_point_constants ("LLFRACT", "LLR",
					    long_long_fract_type_node);
      builtin_define_fixed_point_constants ("ULLFRACT", "ULLR",
					    unsigned_long_long_fract_type_node);
      builtin_define_fixed_point_constants ("SACCUM", "HK",
					    short_accum_type_node);
      builtin_define_fixed_point_constants ("USACCUM", "UHK",
					    unsigned_short_accum_type_node);
      builtin_define_fixed_point_constants ("ACCUM", "K",
					    accum_type_node);
      builtin_define_fixed_point_constants ("UACCUM", "UK",
					    unsigned_accum_type_node);
      builtin_define_fixed_point_constants ("LACCUM", "LK",
					    long_accum_type_node);
      builtin_define_fixed_point_constants ("ULACCUM", "ULK",
					    unsigned_long_accum_type_node);
      builtin_define_fixed_point_constants ("LLACCUM", "LLK",
					    long_long_accum_type_node);
      builtin_define_fixed_point_constants ("ULLACCUM", "ULLK",
					    unsigned_long_long_accum_type_node);

      builtin_define_fixed_point_constants ("QQ", "", qq_type_node);
      builtin_define_fixed_point_constants ("HQ", "", hq_type_node);
      builtin_define_fixed_point_constants ("SQ", "", sq_type_node);
      builtin_define_fixed_point_constants ("DQ", "", dq_type_node);
      builtin_define_fixed_point_constants ("TQ", "", tq_type_node);
      builtin_define_fixed_point_constants ("UQQ", "", uqq_type_node);
      builtin_define_fixed_point_constants ("UHQ", "", uhq_type_node);
      builtin_define_fixed_point_constants ("USQ", "", usq_type_node);
      builtin_define_fixed_point_constants ("UDQ", "", udq_type_node);
      builtin_define_fixed_point_constants ("UTQ", "", utq_type_node);
      builtin_define_fixed_point_constants ("HA", "", ha_type_node);
      builtin_define_fixed_point_constants ("SA", "", sa_type_node);
      builtin_define_fixed_point_constants ("DA", "", da_type_node);
      builtin_define_fixed_point_constants ("TA", "", ta_type_node);
      builtin_define_fixed_point_constants ("UHA", "", uha_type_node);
      builtin_define_fixed_point_constants ("USA", "", usa_type_node);
      builtin_define_fixed_point_constants ("UDA", "", uda_type_node);
      builtin_define_fixed_point_constants ("UTA", "", uta_type_node);
    }

  /* For use in assembly language.  */
  builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
  builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);

  /* Misc.  */
  builtin_define_with_value ("__VERSION__", version_string, 1);

  if (flag_gnu89_inline)
    cpp_define (pfile, "__GNUC_GNU_INLINE__");
  else
    cpp_define (pfile, "__GNUC_STDC_INLINE__");

  /* Definitions for LP64 model.  */
  if (TYPE_PRECISION (long_integer_type_node) == 64
      && POINTER_SIZE == 64
      && TYPE_PRECISION (integer_type_node) == 32)
    {
      cpp_define (pfile, "_LP64");
      cpp_define (pfile, "__LP64__");
    }

  /* Other target-independent built-ins determined by command-line
     options.  */
  if (optimize_size)
    cpp_define (pfile, "__OPTIMIZE_SIZE__");
  if (optimize)
    cpp_define (pfile, "__OPTIMIZE__");

  if (fast_math_flags_set_p ())
    cpp_define (pfile, "__FAST_MATH__");
  if (flag_no_inline)
    cpp_define (pfile, "__NO_INLINE__");
  if (flag_signaling_nans)
    cpp_define (pfile, "__SUPPORT_SNAN__");
  if (flag_finite_math_only)
    cpp_define (pfile, "__FINITE_MATH_ONLY__=1");
  else
    cpp_define (pfile, "__FINITE_MATH_ONLY__=0");
  if (flag_pic)
    {
      builtin_define_with_int_value ("__pic__", flag_pic);
      builtin_define_with_int_value ("__PIC__", flag_pic);
    }
  if (flag_pie)
    {
      builtin_define_with_int_value ("__pie__", flag_pie);
      builtin_define_with_int_value ("__PIE__", flag_pie);
    }

  if (flag_iso)
    cpp_define (pfile, "__STRICT_ANSI__");

  if (!flag_signed_char)
    cpp_define (pfile, "__CHAR_UNSIGNED__");

  if (c_dialect_cxx () && TYPE_UNSIGNED (wchar_type_node))
    cpp_define (pfile, "__WCHAR_UNSIGNED__");

  /* Define a macro indicating whether the thread safety attributes/analysis
     is supported.  */
  if (warn_thread_safety)
    {
      cpp_define (pfile, "__SUPPORT_TS_ANNOTATION__");
      cpp_define (pfile, "__SUPPORT_DYN_ANNOTATION__");
    }

  /* Tell source code if the compiler makes sync_compare_and_swap
     builtins available.  */
#ifdef HAVE_sync_compare_and_swapqi
  if (HAVE_sync_compare_and_swapqi)
    cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
#endif

#ifdef HAVE_sync_compare_and_swaphi
  if (HAVE_sync_compare_and_swaphi)
    cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
#endif

#ifdef HAVE_sync_compare_and_swapsi
  if (HAVE_sync_compare_and_swapsi)
    cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
#endif

#ifdef HAVE_sync_compare_and_swapdi
  if (HAVE_sync_compare_and_swapdi)
    cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
#endif

#ifdef HAVE_sync_compare_and_swapti
  if (HAVE_sync_compare_and_swapti)
    cpp_define (pfile, "__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");
#endif

#ifdef DWARF2_UNWIND_INFO
  if (dwarf2out_do_cfi_asm ())
    cpp_define (pfile, "__GCC_HAVE_DWARF2_CFI_ASM");
#endif

  /* Make the choice of ObjC runtime visible to source code.  */
  if (c_dialect_objc () && flag_next_runtime)
    cpp_define (pfile, "__NEXT_RUNTIME__");

  /* Show the availability of some target pragmas.  */
  if (flag_mudflap || targetm.handle_pragma_redefine_extname)
    cpp_define (pfile, "__PRAGMA_REDEFINE_EXTNAME");

  if (targetm.handle_pragma_extern_prefix)
    cpp_define (pfile, "__PRAGMA_EXTERN_PREFIX");

  /* Make the choice of the stack protector runtime visible to source code.
     The macro names and values here were chosen for compatibility with an
     earlier implementation, i.e. ProPolice.  */
  if (flag_stack_protect == 2)
    cpp_define (pfile, "__SSP_ALL__=2");
  else if (flag_stack_protect == 1)
    cpp_define (pfile, "__SSP__=1");

  if (flag_openmp)
    cpp_define (pfile, "_OPENMP=200805");

  builtin_define_type_sizeof ("__SIZEOF_INT__", integer_type_node);
  builtin_define_type_sizeof ("__SIZEOF_LONG__", long_integer_type_node);
  builtin_define_type_sizeof ("__SIZEOF_LONG_LONG__",
			      long_long_integer_type_node);
  builtin_define_type_sizeof ("__SIZEOF_SHORT__", short_integer_type_node);
  builtin_define_type_sizeof ("__SIZEOF_FLOAT__", float_type_node);
  builtin_define_type_sizeof ("__SIZEOF_DOUBLE__", double_type_node);
  builtin_define_type_sizeof ("__SIZEOF_LONG_DOUBLE__", long_double_type_node);
  builtin_define_type_sizeof ("__SIZEOF_SIZE_T__", size_type_node);
  builtin_define_type_sizeof ("__SIZEOF_WCHAR_T__", wchar_type_node);
  builtin_define_type_sizeof ("__SIZEOF_WINT_T__", wint_type_node);
  builtin_define_type_sizeof ("__SIZEOF_PTRDIFF_T__",
			      unsigned_ptrdiff_type_node);
  /* ptr_type_node can't be used here since ptr_mode is only set when
     toplev calls backend_init which is not done with -E switch.  */
  builtin_define_with_int_value ("__SIZEOF_POINTER__",
				 POINTER_SIZE / BITS_PER_UNIT);

  /* A straightforward target hook doesn't work, because of problems
     linking that hook's body when part of non-C front ends.  */
# define preprocessing_asm_p() (cpp_get_options (pfile)->lang == CLK_ASM)
# define preprocessing_trad_p() (cpp_get_options (pfile)->traditional)
# define builtin_define(TXT) cpp_define (pfile, TXT)
# define builtin_assert(TXT) cpp_assert (pfile, TXT)
  TARGET_CPU_CPP_BUILTINS ();
  TARGET_OS_CPP_BUILTINS ();
  TARGET_OBJFMT_CPP_BUILTINS ();

  /* Support the __declspec keyword by turning them into attributes.
     Note that the current way we do this may result in a collision
     with predefined attributes later on.  This can be solved by using
     one attribute, say __declspec__, and passing args to it.  The
     problem with that approach is that args are not accumulated: each
     new appearance would clobber any existing args.  */
  if (TARGET_DECLSPEC)
    builtin_define ("__declspec(x)=__attribute__((x))");

  /* If decimal floating point is supported, tell the user if the
     alternate format (BID) is used instead of the standard (DPD)
     format.  */
  if (ENABLE_DECIMAL_FLOAT && ENABLE_DECIMAL_BID_FORMAT)
    cpp_define (pfile, "__DECIMAL_BID_FORMAT__");

  builtin_define_with_int_value ("__BIGGEST_ALIGNMENT__",
				 BIGGEST_ALIGNMENT / BITS_PER_UNIT);
}
Exemple #21
0
/* Return the value for __GCC_IEC_559.  */
static int
cpp_iec_559_value (void)
{
  /* The default is support for IEEE 754-2008.  */
  int ret = 2;

  /* float and double must be binary32 and binary64.  If they are but
     with reversed NaN convention, at most IEEE 754-1985 is
     supported.  */
  const struct real_format *ffmt
    = REAL_MODE_FORMAT (TYPE_MODE (float_type_node));
  const struct real_format *dfmt
    = REAL_MODE_FORMAT (TYPE_MODE (double_type_node));
  if (!ffmt->qnan_msb_set || !dfmt->qnan_msb_set)
    ret = 1;
  if (ffmt->b != 2
      || ffmt->p != 24
      || ffmt->pnan != 24
      || ffmt->emin != -125
      || ffmt->emax != 128
      || ffmt->signbit_rw != 31
      || ffmt->round_towards_zero
      || !ffmt->has_sign_dependent_rounding
      || !ffmt->has_nans
      || !ffmt->has_inf
      || !ffmt->has_denorm
      || !ffmt->has_signed_zero
      || dfmt->b != 2
      || dfmt->p != 53
      || dfmt->pnan != 53
      || dfmt->emin != -1021
      || dfmt->emax != 1024
      || dfmt->signbit_rw != 63
      || dfmt->round_towards_zero
      || !dfmt->has_sign_dependent_rounding
      || !dfmt->has_nans
      || !dfmt->has_inf
      || !dfmt->has_denorm
      || !dfmt->has_signed_zero)
    ret = 0;

  /* In strict C standards conformance mode, consider unpredictable
     excess precision to mean lack of IEEE 754 support.  The same
     applies to unpredictable contraction.  For C++, and outside
     strict conformance mode, do not consider these options to mean
     lack of IEEE 754 support.  */
  if (flag_iso
      && !c_dialect_cxx ()
      && TARGET_FLT_EVAL_METHOD != 0
      && flag_excess_precision_cmdline != EXCESS_PRECISION_STANDARD)
    ret = 0;
  if (flag_iso
      && !c_dialect_cxx ()
      && flag_fp_contract_mode == FP_CONTRACT_FAST)
    ret = 0;

  /* Various options are contrary to IEEE 754 semantics.  */
  if (flag_unsafe_math_optimizations
      || flag_associative_math
      || flag_reciprocal_math
      || flag_finite_math_only
      || !flag_signed_zeros
      || flag_single_precision_constant)
    ret = 0;

  /* If the target does not support IEEE 754 exceptions and rounding
     modes, consider IEEE 754 support to be absent.  */
  if (!targetm.float_exceptions_rounding_supported_p ())
    ret = 0;

  return ret;
}