comparison dmd/declaration.c @ 92:70d6113eeb8c trunk

[svn r96] Updated to DMD 1.023. Regular bugfixes.
author lindquist
date Thu, 08 Nov 2007 19:13:28 +0100
parents d8dd47ef3973
children 5071469303d4
comparison
equal deleted inserted replaced
91:3f949c6e2e9d 92:70d6113eeb8c
768 error("reference to scope class must be scope"); 768 error("reference to scope class must be scope");
769 } 769 }
770 } 770 }
771 771
772 if (!init && !sc->inunion && !isStatic() && !isConst() && fd && 772 if (!init && !sc->inunion && !isStatic() && !isConst() && fd &&
773 !(storage_class & (STCfield | STCin | STCforeach))) 773 !(storage_class & (STCfield | STCin | STCforeach)) &&
774 type->size() != 0)
774 { 775 {
775 // Provide a default initializer 776 // Provide a default initializer
776 //printf("Providing default initializer for '%s'\n", toChars()); 777 //printf("Providing default initializer for '%s'\n", toChars());
777 if (type->ty == Tstruct && 778 if (type->ty == Tstruct &&
778 ((TypeStruct *)type)->sym->zeroInit == 1) 779 ((TypeStruct *)type)->sym->zeroInit == 1)
861 e1 = new VarExp(loc, this); 862 e1 = new VarExp(loc, this);
862 863
863 t = type->toBasetype(); 864 t = type->toBasetype();
864 if (t->ty == Tsarray) 865 if (t->ty == Tsarray)
865 { 866 {
866 dim = ((TypeSArray *)t)->dim->toInteger(); 867 ei->exp = ei->exp->semantic(sc);
867 // If multidimensional static array, treat as one large array 868 if (!ei->exp->implicitConvTo(type))
868 while (1)
869 { 869 {
870 t = t->next->toBasetype(); 870 dim = ((TypeSArray *)t)->dim->toInteger();
871 if (t->ty != Tsarray) 871 // If multidimensional static array, treat as one large array
872 break; 872 while (1)
873 if (t->next->toBasetype()->ty == Tbit) 873 {
874 // t->size() gives size in bytes, convert to bits 874 t = t->nextOf()->toBasetype();
875 dim *= t->size() * 8; 875 if (t->ty != Tsarray)
876 else 876 break;
877 dim *= ((TypeSArray *)t)->dim->toInteger(); 877 dim *= ((TypeSArray *)t)->dim->toInteger();
878 e1->type = new TypeSArray(t->next, new IntegerExp(0, dim, Type::tindex)); 878 e1->type = new TypeSArray(t->nextOf(), new IntegerExp(0, dim, Type::tindex));
879 }
879 } 880 }
880 e1 = new SliceExp(loc, e1, NULL, NULL); 881 e1 = new SliceExp(loc, e1, NULL, NULL);
881 } 882 }
882 else if (t->ty == Tstruct) 883 else if (t->ty == Tstruct)
883 { 884 {
1040 * or not. 1041 * or not.
1041 */ 1042 */
1042 1043
1043 void VarDeclaration::checkNestedReference(Scope *sc, Loc loc) 1044 void VarDeclaration::checkNestedReference(Scope *sc, Loc loc)
1044 { 1045 {
1045 if (!isDataseg() && parent != sc->parent && parent) 1046 if (parent && !isDataseg() && parent != sc->parent)
1046 { 1047 {
1047 FuncDeclaration *fdv = toParent()->isFuncDeclaration(); 1048 FuncDeclaration *fdv = toParent()->isFuncDeclaration();
1048 FuncDeclaration *fdthis = sc->parent->isFuncDeclaration(); 1049 FuncDeclaration *fdthis = sc->parent->isFuncDeclaration();
1049 1050
1050 if (fdv && fdthis) 1051 if (fdv && fdthis)
1178 void TypeInfoDeclaration::semantic(Scope *sc) 1179 void TypeInfoDeclaration::semantic(Scope *sc)
1179 { 1180 {
1180 assert(linkage == LINKc); 1181 assert(linkage == LINKc);
1181 } 1182 }
1182 1183
1184 /***************************** TypeInfoConstDeclaration **********************/
1185
1186 #if V2
1187 TypeInfoConstDeclaration::TypeInfoConstDeclaration(Type *tinfo)
1188 : TypeInfoDeclaration(tinfo, 0)
1189 {
1190 }
1191 #endif
1192
1193 /***************************** TypeInfoInvariantDeclaration **********************/
1194
1195 #if V2
1196 TypeInfoInvariantDeclaration::TypeInfoInvariantDeclaration(Type *tinfo)
1197 : TypeInfoDeclaration(tinfo, 0)
1198 {
1199 }
1200 #endif
1201
1183 /***************************** TypeInfoStructDeclaration **********************/ 1202 /***************************** TypeInfoStructDeclaration **********************/
1184 1203
1185 TypeInfoStructDeclaration::TypeInfoStructDeclaration(Type *tinfo) 1204 TypeInfoStructDeclaration::TypeInfoStructDeclaration(Type *tinfo)
1186 : TypeInfoDeclaration(tinfo, 0) 1205 : TypeInfoDeclaration(tinfo, 0)
1187 { 1206 {