このページを編集する際は,編集に関する方針に従ってください.[]
概要[]
引数[]
- const cpp_token *token
- unsigned int flags
実装[]
554 /* Interpret TOKEN, an integer with FLAGS as classified by cpplib. */
555 static tree
556 interpret_integer (const cpp_token *token, unsigned int flags)
557 {
558 tree value, type;
559 enum integer_type_kind itk;
560 cpp_num integer;
561 cpp_options *options = cpp_get_options (parse_in);
562
563 integer = cpp_interpret_integer (parse_in, token, flags);
564 integer = cpp_num_sign_extend (integer, options->precision);
565
566 /* The type of a constant with a U suffix is straightforward. */
567 if (flags & CPP_N_UNSIGNED)
568 itk = narrowest_unsigned_type (integer.low, integer.high, flags);
569 else
570 {
571 /* The type of a potentially-signed integer constant varies
572 depending on the base it's in, the standard in use, and the
573 length suffixes. */
574 enum integer_type_kind itk_u
575 = narrowest_unsigned_type (integer.low, integer.high, flags);
576 enum integer_type_kind itk_s
577 = narrowest_signed_type (integer.low, integer.high, flags);
578
579 /* In both C89 and C99, octal and hex constants may be signed or
580 unsigned, whichever fits tighter. We do not warn about this
581 choice differing from the traditional choice, as the constant
582 is probably a bit pattern and either way will work. */
583 if ((flags & CPP_N_RADIX) != CPP_N_DECIMAL)
584 itk = MIN (itk_u, itk_s);
585 else
586 {
587 /* In C99, decimal constants are always signed.
588 In C89, decimal constants that don't fit in long have
589 undefined behavior; we try to make them unsigned long.
590 In GCC's extended C89, that last is true of decimal
591 constants that don't fit in long long, too. */
592
593 itk = itk_s;
594 if (itk_s > itk_u && itk_s > itk_long)
595 {
596 if (!flag_isoc99)
597 {
598 if (itk_u < itk_unsigned_long)
599 itk_u = itk_unsigned_long;
600 itk = itk_u;
601 warning (0, "this decimal constant is unsigned only in ISO C90");
602 }
603 else
604 warning (OPT_Wtraditional,
605 "this decimal constant would be unsigned in ISO C90");
606 }
607 }
608 }
609
610 if (itk == itk_none)
611 /* cpplib has already issued a warning for overflow. */
612 type = ((flags & CPP_N_UNSIGNED)
613 ? widest_unsigned_literal_type_node
614 : widest_integer_literal_type_node);
615 else
616 type = integer_types[itk];
617
618 if (itk > itk_unsigned_long
619 && (flags & CPP_N_WIDTH) != CPP_N_LARGE
620 && !in_system_header && !flag_isoc99)
621 pedwarn ("integer constant is too large for %qs type",
622 (flags & CPP_N_UNSIGNED) ? "unsigned long" : "long");
623
624 value = build_int_cst_wide (type, integer.low, integer.high);
625
626 /* Convert imaginary to a complex type. */
627 if (flags & CPP_N_IMAGINARY)
628 value = build_complex (NULL_TREE, build_int_cst (type, 0), value);
629
630 return value;
631 }