comparison dmd/constfold.c @ 1621:fb2e6707ad17

Merge DMD r314+r315: bugzilla 2029 Typesafe variadic functions don't... Both DMD revisions are for fixing bugzilla 2029 (Typesafe variadic functions don't work in CTFE). The DMD r314 commit message is: bugzilla 2029 (Typesafe variadic functions don't work in CTFE The DMD r315 commit message is: bugzilla 2029 - try again --- dmd/constfold.c | 11 ++++- dmd/declaration.c | 21 +++++++++- dmd/declaration.h | 10 ++++- dmd/expression.c | 1 + dmd/interpret.c | 111 +++++++++++++++++++++++++++++++++++++++++++++-------- dmd/mars.h | 2 +- dmd/mtype.c | 2 +- 7 files changed, 135 insertions(+), 23 deletions(-)
author Leandro Lucarella <llucax@gmail.com>
date Wed, 06 Jan 2010 15:18:22 -0300
parents def7a1d494fd
children
comparison
equal deleted inserted replaced
1620:0333945a915e 1621:fb2e6707ad17
861 e = new IntegerExp(loc, cmp, type); 861 e = new IntegerExp(loc, cmp, type);
862 return e; 862 return e;
863 } 863 }
864 864
865 Expression *Identity(enum TOK op, Type *type, Expression *e1, Expression *e2) 865 Expression *Identity(enum TOK op, Type *type, Expression *e1, Expression *e2)
866 { Expression *e; 866 {
867 Loc loc = e1->loc; 867 Loc loc = e1->loc;
868 int cmp; 868 int cmp;
869 869
870 if (e1->op == TOKnull) 870 if (e1->op == TOKnull)
871 { 871 {
1053 //printf("e1->type = %s\n", e1->type->toChars()); 1053 //printf("e1->type = %s\n", e1->type->toChars());
1054 if (type->equals(e1->type) && to->equals(type)) 1054 if (type->equals(e1->type) && to->equals(type))
1055 return e1; 1055 return e1;
1056 1056
1057 Type *tb = to->toBasetype(); 1057 Type *tb = to->toBasetype();
1058 Type *typeb = type->toBasetype();
1058 1059
1059 /* Allow casting from one string type to another 1060 /* Allow casting from one string type to another
1060 */ 1061 */
1061 if (e1->op == TOKstring) 1062 if (e1->op == TOKstring)
1062 { 1063 {
1063 Type *typeb = type->toBasetype();
1064 if (tb->ty == Tarray && typeb->ty == Tarray && 1064 if (tb->ty == Tarray && typeb->ty == Tarray &&
1065 tb->nextOf()->size() == typeb->nextOf()->size()) 1065 tb->nextOf()->size() == typeb->nextOf()->size())
1066 { 1066 {
1067 return expType(to, e1); 1067 return expType(to, e1);
1068 } 1068 }
1069 } 1069 }
1070 1070
1071 if (e1->op == TOKarrayliteral && typeb == tb)
1072 {
1073 return e1;
1074 }
1075
1071 if (e1->isConst() != 1) 1076 if (e1->isConst() != 1)
1077 {
1072 return EXP_CANT_INTERPRET; 1078 return EXP_CANT_INTERPRET;
1079 }
1073 1080
1074 if (tb->ty == Tbool) 1081 if (tb->ty == Tbool)
1075 e = new IntegerExp(loc, e1->toInteger() != 0, type); 1082 e = new IntegerExp(loc, e1->toInteger() != 0, type);
1076 else if (type->isintegral()) 1083 else if (type->isintegral())
1077 { 1084 {