~siretart/aspectc++/debian

« back to all changes in this revision

Viewing changes to Puma/src/parser/cparser/CSemantic.cc

  • Committer: Reinhard Tartler
  • Date: 2013-10-13 18:22:49 UTC
  • mfrom: (1.2.8)
  • Revision ID: siretart@tauware.de-20131013182249-fv725vy5ikslptpj
new upstream relesae

Show diffs side-by-side

added added

removed removed

Lines of Context:
662
662
    // determine the underlying type of the enumeration,
663
663
    // must be big enough to hold all enumerator values
664
664
    type = enuminfo->UnderlyingType ();
665
 
    bool long_gt_int = LONG_SIZE > INT_SIZE;
 
665
    bool long_gt_int = CTYPE_LONG.Size () > CTYPE_INT.Size ();
 
666
    long int size = CTypePrimitive::SizeOfNumber (value);
666
667
    if (value < 0) {
667
668
      // signed type
668
669
      if (type->is_unsigned ()) {
669
670
        type = long_gt_int && *type == CTYPE_UNSIGNED_INT ? &CTYPE_LONG : &CTYPE_LONG_LONG;
670
 
      } else if (value < LONG_MIN) {
 
671
      } else if (size > CTYPE_LONG_LONG.Size()) {
 
672
        type = &CTYPE_INT128;
 
673
      } else if (size > CTYPE_LONG.Size()) {
671
674
        type = &CTYPE_LONG_LONG;
672
 
      } else if (value < INT_MIN) {
 
675
      } else if (size > CTYPE_INT.Size()) {
673
676
        type = long_gt_int && *type == CTYPE_INT ? &CTYPE_LONG : &CTYPE_LONG_LONG;
674
677
      }
675
678
    } else {
676
679
      // unsigned, if value cannot be represented by a
677
680
      // signed type and no other value is signed
678
681
      bool is_unsigned = numenums == 1 || type->is_unsigned ();
679
 
      if (value <= INT_MAX) {
 
682
      if (size <= CTYPE_INT.Size()) {
680
683
        type = &CTYPE_INT;
681
 
      } else if (value <= UINT_MAX) {
 
684
      } else if (size <= CTYPE_UNSIGNED_INT.Size()) {
682
685
        type = is_unsigned ? &CTYPE_UNSIGNED_INT : long_gt_int ? &CTYPE_LONG : &CTYPE_LONG_LONG;
683
 
      } else if (value <= LONG_MAX) {
 
686
      } else if (size <= CTYPE_LONG.Size()) {
684
687
        type = &CTYPE_LONG;
685
 
      } else if (value <= ULONG_MAX) {
 
688
      } else if (size <= CTYPE_UNSIGNED_LONG.Size()) {
686
689
        type = is_unsigned ? &CTYPE_UNSIGNED_LONG : &CTYPE_LONG_LONG;
687
 
      } else if (value <= LLONG_MAX) {
 
690
      } else if (size <= CTYPE_LONG_LONG.Size()) {
688
691
        type = &CTYPE_LONG_LONG;
 
692
      } else if (size <= CTYPE_UNSIGNED_LONG_LONG.Size()) {
 
693
        type = &CTYPE_UNSIGNED_LONG_LONG;
689
694
      } else {
690
 
        type = is_unsigned ? &CTYPE_UNSIGNED_LONG_LONG : &CTYPE_LONG_LONG;
 
695
        type = is_unsigned ? &CTYPE_UNSIGNED_INT128 : &CTYPE_INT128;
691
696
      }
692
697
    }
693
698
    if (enuminfo->UnderlyingType ()->rank () < type->rank ()) {
1294
1299
            type == CT_PrimDeclSpec::PDS_FLOAT ||
1295
1300
            type == CT_PrimDeclSpec::PDS_DOUBLE || 
1296
1301
            type == CT_PrimDeclSpec::PDS_INT64 || 
 
1302
            type == CT_PrimDeclSpec::PDS_INT128 || 
1297
1303
            type == CT_PrimDeclSpec::PDS_UNKNOWN_T || 
1298
1304
            type == CT_PrimDeclSpec::PDS_VOID)
1299
1305
          return (CTree*)0;