~ubuntu-branches/ubuntu/utopic/aspectc++/utopic

« back to all changes in this revision

Viewing changes to Puma/gen-release/step1/src/CCOverloading.cc

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2006-04-07 11:56:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060407115635-e8wfgmetasrf2p27
Tags: 0.99+1.0pre3-1
* new upstream release
* Apply patch from Martin Michlmayr for g++-4.1 (Closes: #357901)
* further (simple) patches in Puma/ and AspectC++ for g++-4.1
* note that Puma needs to be rewoven so that it can be compiled
  with g++-4.1. This will be done we switch the default compiler
  version.
* Patch JoinPointRepo.cc so that it doesn't loop endlessly anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
644
644
    len1 = types1.length ();
645
645
    for (unsigned i = 0; i < len0; i++) {
646
646
      t0 = types0[i];
 
647
      if (t0->TypeAddress ()) {
 
648
        t0 = t0->BaseType ();
 
649
      }
647
650
    
648
651
      for (unsigned j = 0; j < len1; j++) {
649
652
        t1 = types1[j];
 
653
        if (t1 && t1->TypeAddress ()) {
 
654
          t1 = t1->BaseType ();
 
655
        }
650
656
        
651
657
        // operator ++
652
658
        if (oper == TOK_INCR)
712
718
void CCOverloading::createIncrOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) { 
713
719
  CTypeInfo *t;
714
720
  
715
 
  if (t1) // check operands
 
721
  if (t1) // unary operators do not have two operands
716
722
    return;
717
723
  
718
724
  if (t0->isConst ()) 
734
740
  // operator functions of the form
735
741
  //   T*VQ& operator++(T*VQ&);
736
742
  //   T*    operator++(T*VQ&, int);
737
 
  if (t0->isObject ()) {
738
 
    t = new CTypePointer (t0->UnqualType ()->Duplicate ());
 
743
  if (t0->isObject () && t0->isPointer ()) {
 
744
    t = t0->UnqualType ()->Duplicate ();
739
745
    if (t0->isVolatile ())
740
746
      t = new CTypeQualified (t, false, true, false);
741
747
    t = new CTypeAddress (t);
742
 
    t0 = new CTypePointer (t0->UnqualType ()->Duplicate ());
 
748
    t0 = t0->UnqualType ()->Duplicate ();
743
749
    createOperator (opname, t, t->Duplicate ());
744
750
    createOperator (opname, t0, t->Duplicate (), &CTYPE_INT);
745
751
  }
750
756
void CCOverloading::createDecrOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
751
757
  CTypeInfo *t;
752
758
  
753
 
  if (t1) 
 
759
  if (t1) // unary operators do not have two operands
754
760
    return;
755
761
 
756
762
  if (t0->isConst ()) 
773
779
  // operator functions of the form
774
780
  //   T*VQ& operator--(T*VQ&);
775
781
  //   T*    operator--(T*VQ&, int);
776
 
  if (t0->isObject ()) {
777
 
    t = new CTypePointer (t0->UnqualType ()->Duplicate ());
 
782
  if (t0->isObject () && t0->isPointer ()) {
 
783
    t = t0->UnqualType ()->Duplicate ();
778
784
    if (t0->isVolatile ())
779
785
      t = new CTypeQualified (t, false, true, false);
780
786
    t = new CTypeAddress (t);
781
 
    t0 = new CTypePointer (t0->UnqualType ()->Duplicate ());
 
787
    t0 = t0->UnqualType ()->Duplicate ();
782
788
    createOperator (opname, t, t->Duplicate ());
783
789
    createOperator (opname, t0, t->Duplicate (), &CTYPE_INT);
784
790
  }
795
801
  // 7. For every function type T, there exist candidate operator functions 
796
802
  // of the form
797
803
  //   T& operator*(T*);
798
 
  if (! t1) {
799
 
    createOperator (opname, new CTypeAddress (t0->Duplicate ()), 
800
 
                    new CTypePointer (t0->Duplicate ()));
 
804
  if (! t1 && t0->isPointer ()) {
 
805
    t = new CTypeAddress (t0->PtrBaseType ()->Duplicate ());
 
806
    createOperator (opname, t, t0->Duplicate ());
801
807
  }
802
808
 
803
809
  // 12. For every pair of promoted arithmetic types L and R, there exist 
819
825
  
820
826
  // 8. For every type T, there exist candidate operator functions of the form
821
827
  //   T* operator+(T*);
822
 
  if (! t1) {
823
 
    t = new CTypePointer (t0->Duplicate ());
824
 
    createOperator (opname, t, t->Duplicate ());
 
828
  if (! t1 && t0->isPointer ()) {
 
829
    createOperator (opname, t0->Duplicate (), t0->Duplicate ());
825
830
  }
826
831
 
827
832
  // 13. For every cv-qualified or cv-unqualified object type T there exist 
828
833
  // candidate operator functions of the form
829
834
  //   T* operator+(T*, ptrdiff_t);
830
835
  //   T* operator+(ptrdiff_t, T*);
831
 
  if (! t1 && t0->isObject ()) {                             /* ptrdiff_t */
832
 
    createOperator (opname, t->Duplicate (), t->Duplicate (), CTypeInfo::CTYPE_PTRDIFF_T);
833
 
    createOperator (opname, t->Duplicate (), CTypeInfo::CTYPE_PTRDIFF_T, t->Duplicate ());
834
 
  }                                         /* ptrdiff_t */
 
836
  if (t1 && t0->isObject () && t0->isPointer ()) {          
 
837
    t = CTypeInfo::CTYPE_PTRDIFF_T; // ptrdiff_t
 
838
    createOperator (opname, t0->Duplicate (), t0->Duplicate (), t);
 
839
    createOperator (opname, t0->Duplicate (), t, t0->Duplicate ());
 
840
  }                                          
835
841
 
836
842
  // 9. For every promoted arithmetic type T, there exist candidate operator 
837
843
  // functions of the form
856
862
 
857
863
// operator -
858
864
void CCOverloading::createMinusOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
859
 
  CTypeInfo *t;
 
865
  CTypeInfo *t = 0;
860
866
  
861
867
  // 13. For every cv-qualified or cv-unqualified object type T there exist 
862
868
  // candidate operator functions of the form
863
869
  //   T* operator-(T*, ptrdiff_t);
864
 
  if (! t1 && t0->isObject ()) {                                     
865
 
    t = new CTypePointer (t0->Duplicate ());   /* ptrdiff_t */
866
 
    createOperator (opname, t, t->Duplicate (), CTypeInfo::CTYPE_PTRDIFF_T);
 
870
  if (t1 && t0->isObject () && t0->isPointer ()) {
 
871
    createOperator (opname, t0->Duplicate (), t0->Duplicate (), t);
867
872
  }
868
873
 
869
874
  // 14. For every T, where T is a pointer to object type, there exist candidate
870
875
  // operator functions of the form
871
876
  //   ptrdiff_t operator-(T, T);
872
 
  if (! t1 && t0->isPointer () && t0->VirtualType ()->BaseType ()->isObject ()) {
873
 
    createOperator (opname, CTypeInfo::CTYPE_PTRDIFF_T, t0->Duplicate (), 
874
 
                    t0->Duplicate ()); /* ptrdiff_t */
 
877
  if (t1 && t0->isPointer () && t0->PtrBaseType ()->isObject ()) {
 
878
    t = CTypeInfo::CTYPE_PTRDIFF_T; // ptrdiff_t
 
879
    createOperator (opname, t, t0->Duplicate (), t0->Duplicate ());
 
880
  }                        
 
881
  if (t1 && t1->isPointer () && t1->PtrBaseType ()->isObject ()) {
 
882
    t = CTypeInfo::CTYPE_PTRDIFF_T; // ptrdiff_t
 
883
    createOperator (opname, t, t1->Duplicate (), t1->Duplicate ());
875
884
  }                        
876
885
 
877
886
  // 9. For every promoted arithmetic type T, there exist candidate operator 
897
906
 
898
907
// operator ~
899
908
void CCOverloading::createTildeOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
900
 
  if (t1)      // check operands
 
909
  if (t1) // unary operators do not have two operands
901
910
    return;
902
911
 
903
912
  // 10. For every promoted integral type T, there exist candidate operator 
915
924
  CTypeInfo *t;
916
925
  CRecord *c0, *c1;
917
926
  
918
 
  if (! t1)
 
927
  if (! t1) // binary operators must have two operands
919
928
    return;
920
929
 
921
930
  // 11. For every quintuple (C1, C2, T, CV1, CV2), where C2 is a class type, 
949
958
 
950
959
// operator []
951
960
void CCOverloading::createIndexOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
952
 
  CTypeInfo *rt, *pt;
 
961
  CTypeInfo *rt, *pt, *t;
953
962
  
954
 
  if (t1)
 
963
  if (! t1) // binary operators must have two operands
955
964
    return;
956
 
 
 
965
  
957
966
  // 13. For every cv-qualified or cv-unqualified object type T there exist 
958
967
  // candidate operator functions of the form
959
968
  //   T& operator[](T*, ptrdiff_t);
960
969
  //   T& operator[](ptrdiff_t, T*);
961
 
  if (t0->isObject ()) {
962
 
    rt = new CTypeAddress (t0->Duplicate ());
963
 
    pt = new CTypePointer (t0->Duplicate ());
964
 
    createOperator (opname, rt, pt, CTypeInfo::CTYPE_PTRDIFF_T); /* ptrdiff_t */
965
 
    createOperator (opname, rt->Duplicate (), CTypeInfo::CTYPE_PTRDIFF_T, 
966
 
                    pt->Duplicate ());        /* ptrdiff_t */
 
970
  if (t0->isObject () && t0->isPointer ()) {
 
971
    rt = new CTypeAddress (t0->PtrBaseType ()->Duplicate ());
 
972
    pt = t0->Duplicate ();
 
973
    t = CTypeInfo::CTYPE_PTRDIFF_T; // ptrdiff_t
 
974
    createOperator (opname, rt, pt, t); 
 
975
    createOperator (opname, rt->Duplicate (), t, pt->Duplicate ());
967
976
  }
968
977
}
969
978
 
971
980
// operator ?
972
981
void CCOverloading::createIfThenOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
973
982
  CTypeInfo *t;
 
983
 
 
984
  if (! t1) // binary operators must have two operands
 
985
    return;
974
986
  
975
987
  // 25. For every type T, where T is a pointer or pointer-to-member type, there exist 
976
988
  // candidate operator functions of the form
977
989
  //   T operator?(bool, T, T);   // first operand skipped!!!
978
 
  if (! t1 && (t0->isMemberPointer () || t0->isPointer ())) {
 
990
  if (t0->isMemberPointer () || t0->isPointer ()) {
979
991
    createOperator (opname, t0->Duplicate (), t0->Duplicate (), t0->Duplicate ());
980
992
  }
 
993
  if (t1->isMemberPointer () || t1->isPointer ()) {
 
994
    createOperator (opname, t1->Duplicate (), t1->Duplicate (), t1->Duplicate ());
 
995
  }
981
996
 
982
997
  // 24. For every pair of promoted arithmetic types L and R, there exist candidate 
983
998
  // operator functions of the form (where LR is the result of the usual arithmetic 
984
999
  // conversions between types L and R)
985
1000
  //   LR operator?(bool, L, R);   // first operand skipped!!!
986
 
  if (t1 && t0->isArithmetic () && t1->isArithmetic ()) {
 
1001
  if (t0->isArithmetic () && t1->isArithmetic ()) {
987
1002
    t0 = cvs.arithmeticPromotion (t0);
988
1003
    t1 = cvs.arithmeticPromotion (t1);
989
1004
    t = cvs.usualArithmeticConv (t0, t1);
1008
1023
 
1009
1024
// operator <, operator >, operator <=, operator >=
1010
1025
void CCOverloading::createRelOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
 
1026
  if (! t1) // binary operators must have two operands
 
1027
    return;
 
1028
 
1011
1029
  // 15. For every pointer or enumeration type T, there exist candidate operator
1012
1030
  // functions of the form
1013
1031
  //   bool operator<(T, T);
1014
1032
  //   bool operator>(T, T);
1015
1033
  //   bool operator<=(T, T);
1016
1034
  //   bool operator>=(T, T);  
1017
 
  if (! t1 && (t0->isPointer () || t0->isEnum ())) {
 
1035
  if (t0->isPointer () || t0->isEnum ()) {
1018
1036
    createOperator (opname, &CTYPE_BOOL, t0->Duplicate (), t0->Duplicate ());
1019
1037
  } 
 
1038
  if (t1->isPointer () || t1->isEnum ()) {
 
1039
    createOperator (opname, &CTYPE_BOOL, t1->Duplicate (), t1->Duplicate ());
 
1040
  } 
1020
1041
  
1021
1042
  // 12. For every pair of promoted arithmetic types L and R, there exist 
1022
1043
  // candidate operator functions of the form (where LR is the result of the 
1025
1046
  //   bool operator>(L, R);
1026
1047
  //   bool operator<=(L, R);
1027
1048
  //   bool operator>=(L, R);
1028
 
  if (t1 && t0->isArithmetic () && t1->isArithmetic ()) {
 
1049
  if (t0->isArithmetic () && t1->isArithmetic ()) {
1029
1050
    t0 = cvs.arithmeticPromotion (t0);
1030
1051
    t1 = cvs.arithmeticPromotion (t1);
1031
1052
    createOperator (opname, &CTYPE_BOOL, t0->Duplicate (), t1->Duplicate ()); 
1037
1058
void CCOverloading::createBinOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
1038
1059
  CTypeInfo *t;
1039
1060
  
1040
 
  if (! t1)
 
1061
  if (! t1) // binary operators must have two operands
1041
1062
    return;
1042
1063
 
1043
1064
  // 17. For every pair of promoted integral types L and R, there exist candidate
1064
1085
 
1065
1086
// operator %=, operator &=, operator ^=, operator |=, operator <<=, operator >>=
1066
1087
void CCOverloading::createEqAssOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
1067
 
  if (! t1)
 
1088
  if (! t1) // binary operators must have two operands
1068
1089
    return;
1069
1090
 
1070
1091
  // 22. For every triple (L, VQ, R), where L is an integral type, VQ is either 
1088
1109
void CCOverloading::createAssOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
1089
1110
  CTypeInfo *t;
1090
1111
  
 
1112
  if (! t1) // binary operators must have two operands
 
1113
    return;
 
1114
 
1091
1115
  if (t0->isConst ()) 
1092
1116
    return;
1093
1117
 
1094
1118
  // 19. For every pair (T, VQ), where T is any type and VQ is either volatile or
1095
1119
  // empty, there exist candidate operator functions of the form
1096
1120
  //   T*VQ& operator=(T*VQ&, T*);
1097
 
  if (! t1) {
1098
 
    t = new CTypePointer (t0->UnqualType ()->Duplicate ());
 
1121
  if (t0->isPointer ()) {
 
1122
    t = t0->UnqualType ()->Duplicate ();
1099
1123
    if (t0->isVolatile ())
1100
1124
      t = new CTypeQualified (t, false, true, false);
1101
1125
    t = new CTypeAddress (t);
1102
 
    createOperator (opname, t, t->Duplicate (), 
1103
 
                    new CTypePointer (t0->UnqualType ()->Duplicate ()));
 
1126
    createOperator (opname, t, t->Duplicate (), t0->UnqualType ()->Duplicate ());
1104
1127
  }
1105
1128
 
1106
1129
  // 20. For every pair (T, VQ), where T is an enumeration or pointer to member type 
1107
1130
  // and VQ is either volatile or empty, there exist candidate operator functions 
1108
1131
  // of the form
1109
1132
  //   VQ T& operator=(VQ T&, T);
1110
 
  if (! t1 && (t0->isMemberPointer () || t0->isEnum ())) {
 
1133
  if (t0->isMemberPointer () || t0->isEnum ()) {
1111
1134
    t = new CTypeAddress (t0->Duplicate ());
1112
1135
    t0 = t0->UnqualType ()->Duplicate ();
1113
1136
    createOperator (opname, t, t->Duplicate (), t0);
1117
1140
  // volatile or empty, and R is a promoted arithmetic type, there exist candidate 
1118
1141
  // operator functions of the form
1119
1142
  //   VQ L& operator=(VQ L&, R);
1120
 
  if (t1 && t0->isArithmetic () && t1->isArithmetic ()) {
 
1143
  if (t0->isArithmetic () && t1->isArithmetic ()) {
1121
1144
    t = new CTypeAddress (t0->Duplicate ());
1122
1145
    t1 = cvs.arithmeticPromotion (t1);
1123
1146
    createOperator (opname, t, t->Duplicate (), t1->Duplicate ()); 
1129
1152
void CCOverloading::createDivOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
1130
1153
  CTypeInfo *t;
1131
1154
  
1132
 
  if (! t1)
 
1155
  if (! t1) // binary operators must have two operands
1133
1156
    return;
1134
1157
 
1135
1158
  // 12. For every pair of promoted arithmetic types L and R, there exist 
1147
1170
 
1148
1171
// operator ==, operator !=
1149
1172
void CCOverloading::createEqOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
 
1173
  if (! t1) // binary operators must have two operands
 
1174
    return;
 
1175
 
1150
1176
  // 15. For every pointer or enumeration type T, there exist candidate operator
1151
1177
  // functions of the form
1152
1178
  //   bool operator==(T, T);
1155
1181
  // functions of the form
1156
1182
  //   bool operator==(T, T);
1157
1183
  //   bool operator!=(T, T);
1158
 
  if (! t1 && (t0->isMemberPointer () || t0->isPointer () || t0->isEnum ())) {
 
1184
  if (t0->isMemberPointer () || t0->isPointer () || t0->isEnum ()) {
1159
1185
    createOperator (opname, &CTYPE_BOOL, t0->Duplicate (), t0->Duplicate ());
1160
1186
  } 
 
1187
  if (t1->isMemberPointer () || t1->isPointer () || t1->isEnum ()) {
 
1188
    createOperator (opname, &CTYPE_BOOL, t1->Duplicate (), t1->Duplicate ());
 
1189
  } 
1161
1190
 
1162
1191
  // 12. For every pair of promoted arithmetic types L and R, there exist 
1163
1192
  // candidate operator functions of the form (where LR is the result of the 
1164
1193
  // usual arithmetic conversions between types L and R)
1165
1194
  //   bool operator==(L, R);
1166
1195
  //   bool operator!=(L, R);     
1167
 
  if (t1 && t0->isArithmetic () && t1->isArithmetic ()) {
 
1196
  if (t0->isArithmetic () && t1->isArithmetic ()) {
1168
1197
    t0 = cvs.arithmeticPromotion (t0);
1169
1198
    t1 = cvs.arithmeticPromotion (t1);
1170
1199
    createOperator (opname, &CTYPE_BOOL, t0->Duplicate (), t1->Duplicate ()); 
1176
1205
void CCOverloading::createMulAssOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
1177
1206
  CTypeInfo *t;
1178
1207
 
1179
 
  if (! t1)
 
1208
  if (! t1) // binary operators must have two operands
1180
1209
    return;
1181
1210
 
1182
1211
  // 18. For every triple (L, VQ, R), where L is an arithmetic type, VQ is either 
1196
1225
void CCOverloading::createAddAssOp (const char *opname, CTypeInfo *t0, CTypeInfo *t1) {
1197
1226
  CTypeInfo *t;
1198
1227
  
 
1228
  if (! t1) // binary operators must have two operands
 
1229
    return;
 
1230
 
1199
1231
  if (t0->isConst ())
1200
1232
    return;
1201
1233
 
1204
1236
  // of the form
1205
1237
  //   T*VQ& operator+=(T*VQ&, ptrdiff_t);
1206
1238
  //   T*VQ& operator-=(T*VQ&, ptrdiff_t);
1207
 
  if (! t1 && t0->isObject ()) {
1208
 
    t = new CTypePointer (t0->UnqualType ()->Duplicate ());
 
1239
  if (t0->isObject () && t0->isPointer ()) {
 
1240
    t = t0->UnqualType ()->Duplicate ();
1209
1241
    if (t0->isVolatile ())
1210
1242
      t = new CTypeQualified (t, false, true, false);
1211
1243
    t = new CTypeAddress (t);                  /* ptrdiff_t */
1217
1249
  // operator functions of the form
1218
1250
  //   VQ L& operator+=(VQ L&, R);
1219
1251
  //   VQ L& operator-=(VQ L&, R);
1220
 
  if (t1 && t0->isArithmetic () && t1->isArithmetic ()) {
 
1252
  if (t0->isArithmetic () && t1->isArithmetic ()) {
1221
1253
    t = new CTypeAddress (t0->Duplicate ());
1222
1254
    t1 = cvs.arithmeticPromotion (t1);
1223
1255
    createOperator (opname, t, t->Duplicate (), t1->Duplicate ());