Changeset 1103:b30fe7e1dbb9
- Timestamp:
- 03/12/09 15:37:27 (3 years ago)
- Files:
-
- CMakeLists.txt (modified) (4 diffs)
- dmd/Doxyfile (deleted)
- dmd/access.c (modified) (1 diff)
- dmd/array.c (modified) (1 diff)
- dmd/arrayop.c (modified) (1 diff)
- dmd/attrib.c (modified) (7 diffs)
- dmd/cast.c (modified) (1 diff)
- dmd/class.c (modified) (2 diffs)
- dmd/cond.c (modified) (5 diffs)
- dmd/cond.h (modified) (1 diff)
- dmd/constfold.c (modified) (6 diffs)
- dmd/dchar.c (modified) (1 diff)
- dmd/declaration.c (modified) (1 diff)
- dmd/doc.c (modified) (1 diff)
- dmd/dsymbol.c (modified) (1 diff)
- dmd/entity.c (modified) (2 diffs)
- dmd/expression.c (modified) (18 diffs)
- dmd/expression.h (modified) (2 diffs)
- dmd/func.c (modified) (6 diffs)
- dmd/hdrgen.c (modified) (1 diff)
- dmd/identifier.c (modified) (1 diff)
- dmd/inifile.c (deleted)
- dmd/interpret.c (modified) (2 diffs)
- dmd/lexer.c (modified) (3 diffs)
- dmd/lstring.c (modified) (1 diff)
- dmd/macro.c (modified) (1 diff)
- dmd/man.c (modified) (3 diffs)
- dmd/mangle.c (modified) (6 diffs)
- dmd/mars.c (modified) (2 diffs)
- dmd/mars.h (modified) (9 diffs)
- dmd/mem.c (modified) (1 diff)
- dmd/module.c (modified) (6 diffs)
- dmd/module.h (modified) (2 diffs)
- dmd/mtype.c (modified) (17 diffs)
- dmd/mtype.h (modified) (4 diffs)
- dmd/opover.c (modified) (3 diffs)
- dmd/optimize.c (modified) (3 diffs)
- dmd/parse.c (modified) (1 diff)
- dmd/rmem.h (added)
- dmd/root.c (modified) (5 diffs)
- dmd/root.h (modified) (1 diff)
- dmd/scope.c (modified) (1 diff)
- dmd/statement.c (modified) (9 diffs)
- dmd/statement.h (modified) (2 diffs)
- dmd/stringtable.c (modified) (1 diff)
- dmd/struct.c (modified) (9 diffs)
- dmd/template.c (modified) (28 diffs)
- dmd/template.h (modified) (7 diffs)
- dmd/total.h (deleted)
- gen/asmstmt.cpp (modified) (2 diffs)
- gen/cl_helpers.cpp (modified) (1 diff)
- gen/configfile.cpp (added)
- gen/configfile.h (added)
- gen/main.cpp (modified) (4 diffs)
- gen/statements.cpp (modified) (1 diff)
- gen/toir.cpp (modified) (2 diffs)
- ldc.conf.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
CMakeLists.txt
r1074 r1103 10 10 endif(NOT PERL) 11 11 12 include(FindPkgConfig) 13 if(NOT PKG_CONFIG_FOUND) 14 message(FATAL_ERROR "pkg-config not found") 15 else(NOT PKG_CONFIG_FOUND) 16 pkg_search_module(LIBCONFIGPP libconfig++) 17 if(NOT LIBCONFIGPP_FOUND) 18 message(FATAL_ERROR "libconfig++ not found") 19 endif(NOT LIBCONFIGPP_FOUND) 20 set(LIBCONFIG_CXXFLAGS ${LIBCONFIGPP_CFLAGS} CACHE STRING "libconfig++ compiler flags") 21 set(LIBCONFIG_LDFLAGS ${LIBCONFIGPP_LDFLAGS} CACHE STRING "libconfig++ linker flags") 22 endif(NOT PKG_CONFIG_FOUND) 23 24 12 25 find_program(LLVM_CONFIG llvm-config ${LLVM_INSTDIR}/bin DOC "path to llvm-config tool") 13 26 # get llvm's install dir. a little hackish, we could do something like llvm-config --prefix, but this does as well … … 40 53 ) 41 54 execute_process( 42 COMMAND ${PERL_EXECUTABLE} ${LLVM_CONFIG} --libfiles bitwriter linker ipo instrumentation backend 55 COMMAND ${PERL_EXECUTABLE} ${LLVM_CONFIG} --libfiles bitwriter linker ipo instrumentation backend arm 43 56 OUTPUT_VARIABLE LLVM_LIBS 44 57 OUTPUT_STRIP_TRAILING_WHITESPACE … … 162 175 add_definitions(-DDEFAULT_TARGET_TRIPLE=\\"${DEFAULT_TARGET}\\") 163 176 add_definitions(-DDEFAULT_ALT_TARGET_TRIPLE=\\"${DEFAULT_ALT_TARGET}\\") 177 add_definitions(-DLDC_INSTALL_PREFIX=\\"${CMAKE_INSTALL_PREFIX}\\") 164 178 else(CMAKE_MINOR_VERSION LESS 6) 165 179 add_definitions(-DDEFAULT_TARGET_TRIPLE="${DEFAULT_TARGET}") 166 180 add_definitions(-DDEFAULT_ALT_TARGET_TRIPLE="${DEFAULT_ALT_TARGET}") 181 add_definitions(-DLDC_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}") 167 182 endif(CMAKE_MINOR_VERSION LESS 6) 168 183 … … 191 206 OUTPUT_NAME ${LDC_EXE_NAME} 192 207 RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin 193 COMPILE_FLAGS "${LLVM_CXXFLAGS} -Wno-deprecated -Wno-write-strings"208 COMPILE_FLAGS "${LLVM_CXXFLAGS} ${LIBCONFIG_CXXFLAGS} -Wno-deprecated -Wno-write-strings" 194 209 ) 195 210 196 211 # LDFLAGS should actually be in target property LINK_FLAGS, but this works, and gets around linking problems 197 target_link_libraries(${LDC_EXE} "${LLVM_LDFLAGS} ${LLVM_LIBS} ")212 target_link_libraries(${LDC_EXE} "${LLVM_LDFLAGS} ${LLVM_LIBS} ${LIBCONFIG_LDFLAGS}") 198 213 if(WIN32) 199 214 target_link_libraries(${LDC_EXE} psapi) dmd/access.c
r336 r1103 14 14 15 15 #include "root.h" 16 #include " mem.h"16 #include "rmem.h" 17 17 18 18 #include "enum.h" dmd/array.c
r872 r1103 42 42 #include "root.h" 43 43 #include "dchar.h" 44 #include " mem.h"44 #include "rmem.h" 45 45 46 46 dmd/arrayop.c
r703 r1103 12 12 #include <assert.h> 13 13 14 #if _WIN32 || IN_GCC || IN_LLVM 15 #include "mem.h" 16 #else 17 #include "../root/mem.h" 18 #endif 14 #include "rmem.h" 19 15 20 16 #include "stringtable.h" dmd/attrib.c
r986 r1103 13 13 #include <assert.h> 14 14 15 #if _WIN32 || IN_GCC || IN_LLVM 16 #include "mem.h" 17 #elif POSIX 18 #include "../root/mem.h" 19 #endif 15 #include "rmem.h" 20 16 21 17 #include "init.h" … … 152 148 //printf("AttribDeclaration::emitComment(sc = %p)\n", sc); 153 149 150 /* A general problem with this, illustrated by BUGZILLA 2516, 151 * is that attributes are not transmitted through to the underlying 152 * member declarations for template bodies, because semantic analysis 153 * is not done for template declaration bodies 154 * (only template instantiations). 155 * Hence, Ddoc omits attributes from template members. 156 */ 157 154 158 Array *d = include(NULL, NULL); 155 159 … … 327 331 { STCextern, TOKextern }, 328 332 { STCconst, TOKconst }, 333 // { STCinvariant, TOKimmutable }, 334 // { STCshared, TOKshared }, 329 335 { STCfinal, TOKfinal }, 330 336 { STCabstract, TOKabstract }, … … 332 338 { STCdeprecated, TOKdeprecated }, 333 339 { STCoverride, TOKoverride }, 340 // { STCnothrow, TOKnothrow }, 341 // { STCpure, TOKpure }, 342 // { STCref, TOKref }, 343 // { STCtls, TOKtls }, 334 344 }; 335 345 … … 613 623 sc = sc->push(); 614 624 sc->anonAgg = &aad; 615 sc->stc &= ~(STCauto | STCscope | STCstatic );625 sc->stc &= ~(STCauto | STCscope | STCstatic | STCtls); 616 626 sc->inunion = isunion; 617 627 sc->offset = 0; … … 754 764 Dsymbol *PragmaDeclaration::syntaxCopy(Dsymbol *s) 755 765 { 766 //printf("PragmaDeclaration::syntaxCopy(%s)\n", toChars()); 756 767 PragmaDeclaration *pd; 757 768 … … 1394 1405 int CompileDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) 1395 1406 { 1396 //printf("CompileDeclaration::addMember(sc = %p )\n", sc);1407 //printf("CompileDeclaration::addMember(sc = %p, memnum = %d)\n", sc, memnum); 1397 1408 this->sd = sd; 1398 1409 if (memnum == 0) dmd/cast.c
r846 r1103 11 11 #include <assert.h> 12 12 13 #if _WIN32 || IN_GCC || IN_LLVM 14 #include "mem.h" 15 #else 16 #include "../root/mem.h" 17 #endif 13 #include "rmem.h" 18 14 19 15 #include "expression.h" dmd/class.c
r875 r1103 14 14 15 15 #include "root.h" 16 #include " mem.h"16 #include "rmem.h" 17 17 18 18 #include "enum.h" … … 858 858 for (size_t i = 0; i < vtbl->dim; i++) 859 859 { 860 FuncDeclaration *fd = (FuncDeclaration *)vtbl->data[i]; 860 FuncDeclaration *fd = ((Dsymbol*)vtbl->data[i])->isFuncDeclaration(); 861 if (!fd) 862 continue; // the first entry might be a ClassInfo 861 863 862 864 //printf("\t[%d] = %s\n", i, fd->toChars()); dmd/cond.c
r990 r1103 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 6by Digital Mars3 // Copyright (c) 1999-2008 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 32 32 for (int i = 0; i < ids->dim; i++) 33 33 { 34 c har *id = (char *)ids->data[i];34 const char *id = (const char *)ids->data[i]; 35 35 36 36 if (strcmp(id, ident->toChars()) == 0) … … 76 76 if (!global.params.debugids) 77 77 global.params.debugids = new Array(); 78 global.params.debugids->push((void *)ident);78 global.params.debugids->push((void *)ident); 79 79 } 80 80 … … 128 128 static const char* reserved[] = 129 129 { 130 "DigitalMars", "LLVM", "LDC", "LLVM64", 131 "X86", "X86_64", "PPC", "PPC64", 130 "DigitalMars", "X86", "X86_64", 132 131 "Windows", "Win32", "Win64", 133 "linux", " darwin", "Posix",132 "linux", "Posix", "OSX", "FreeBSD", 134 133 "LittleEndian", "BigEndian", 135 134 "all", 136 135 "none", 136 137 // LDC 138 "LLVM", "LDC", "LLVM64", 139 "PPC", "PPC64", 140 "darwin", 137 141 }; 138 142 … … 162 166 if (!global.params.versionids) 163 167 global.params.versionids = new Array(); 164 global.params.versionids->push((void *)ident);168 global.params.versionids->push((void *)ident); 165 169 } 166 170 dmd/cond.h
r988 r1103 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 6by Digital Mars3 // Copyright (c) 1999-2008 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright dmd/constfold.c
r735 r1103 18 18 #endif 19 19 20 #include " mem.h"20 #include "rmem.h" 21 21 #include "root.h" 22 22 … … 1173 1173 1174 1174 if (i >= es1->len) 1175 e1->error("string index %llu is out of bounds [0 .. %"PRIuSIZE"]", i, es1->len);1175 e1->error("string index %ju is out of bounds [0 .. %zu]", i, es1->len); 1176 1176 else 1177 1177 { unsigned value = es1->charAt(i); … … 1185 1185 1186 1186 if (i >= length) 1187 { 1188 e2->error("array index %llu is out of bounds %s[0 .. %llu]", i, e1->toChars(), length); 1187 { e2->error("array index %ju is out of bounds %s[0 .. %ju]", i, e1->toChars(), length); 1189 1188 } 1190 1189 else if (e1->op == TOKarrayliteral && !e1->checkSideEffect(2)) … … 1201 1200 { ArrayLiteralExp *ale = (ArrayLiteralExp *)e1; 1202 1201 if (i >= ale->elements->dim) 1203 { 1204 e2->error("array index %llu is out of bounds %s[0 .. %u]", i, e1->toChars(), ale->elements->dim); 1202 { e2->error("array index %ju is out of bounds %s[0 .. %u]", i, e1->toChars(), ale->elements->dim); 1205 1203 } 1206 1204 else … … 1252 1250 1253 1251 if (iupr > es1->len || ilwr > iupr) 1254 e1->error("string slice [%llu .. %llu] is out of bounds", ilwr, iupr);1252 e1->error("string slice [%ju .. %ju] is out of bounds", ilwr, iupr); 1255 1253 else 1256 1254 { integer_t value; … … 1279 1277 1280 1278 if (iupr > es1->elements->dim || ilwr > iupr) 1281 e1->error("array slice [%llu .. %llu] is out of bounds", ilwr, iupr);1279 e1->error("array slice [%ju .. %ju] is out of bounds", ilwr, iupr); 1282 1280 else 1283 1281 { dmd/dchar.c
r1 r1103 15 15 16 16 #include "dchar.h" 17 #include " mem.h"17 #include "rmem.h" 18 18 19 19 #if M_UNICODE dmd/declaration.c
r920 r1103 751 751 752 752 OutBuffer buf; 753 buf.printf("_%s_field_%"PRIuSIZE, ident->toChars(), i);753 buf.printf("_%s_field_%zu", ident->toChars(), i); 754 754 buf.writeByte(0); 755 755 char *name = (char *)buf.extractData(); dmd/doc.c
r876 r1103 17 17 #include <assert.h> 18 18 19 #if IN_GCC || IN_LLVM 20 #include "mem.h" 21 #else 22 #if _WIN32 23 #include "..\root\mem.h" 24 #elif POSIX 25 #include "../root/mem.h" 26 #else 27 #error "fix this" 28 #endif 29 #endif 19 #include "rmem.h" 30 20 31 21 #include "root.h" dmd/dsymbol.c
r946 r1103 13 13 #include <assert.h> 14 14 15 #include " mem.h"15 #include "rmem.h" 16 16 17 17 #include "mars.h" dmd/entity.c
r1 r1103 1 1 2 // Copyright (c) 1999-200 6by Digital Mars2 // Copyright (c) 1999-2009 by Digital Mars 3 3 // All Rights Reserved 4 4 // written by Walter Bright … … 20 20 struct NameId 21 21 { 22 c har *name;22 const char *name; 23 23 unsigned short value; 24 24 }; dmd/expression.c
r1012 r1103 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 8by Digital Mars3 // Copyright (c) 1999-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 12 12 #include <stdlib.h> 13 13 #include <ctype.h> 14 #include <math.h> 14 15 #include <assert.h> 15 16 #if _MSC_VER … … 17 18 #else 18 19 #endif 19 #include <math.h>20 20 21 21 #if _WIN32 && __DMC__ … … 44 44 #endif 45 45 46 #if IN_GCC || IN_LLVM 47 #include "mem.h" 48 #elif _WIN32 49 #include "..\root\mem.h" 50 #elif POSIX 51 #include "../root/mem.h" 52 #endif 46 #include "rmem.h" 53 47 54 48 //#include "port.h" … … 561 555 562 556 if (nargs > nparams && tf->varargs == 0) 563 error(loc, "expected %"PRIuSIZE" arguments, not %"PRIuSIZE, nparams, nargs);557 error(loc, "expected %zu arguments, not %zu", nparams, nargs); 564 558 565 559 n = (nargs > nparams) ? nargs : nparams; // n = max(nargs, nparams) … … 586 580 if (tf->varargs == 2 && i + 1 == nparams) 587 581 goto L2; 588 error(loc, "expected %"PRIuSIZE" arguments, not %"PRIuSIZE, nparams, nargs);582 error(loc, "expected %zu arguments, not %zu", nparams, nargs); 589 583 break; 590 584 } … … 608 602 { 609 603 if (nargs != nparams) 610 error(loc, "expected %"PRIuSIZE" arguments, not %"PRIuSIZE, nparams, nargs);604 error(loc, "expected %zu arguments, not %zu", nparams, nargs); 611 605 goto L1; 612 606 } … … 966 960 } 967 961 962 void Expression::warning(const char *format, ...) 963 { 964 if (global.params.warnings && !global.gag) 965 { 966 fprintf(stdmsg, "warning - "); 967 va_list ap; 968 va_start(ap, format); 969 ::warning(loc, format, ap); 970 va_end( ap ); 971 } 972 } 973 968 974 void Expression::rvalue() 969 975 { … … 1320 1326 #else 1321 1327 static char buffer[sizeof(value) * 3 + 1]; 1322 sprintf(buffer, "%lld", value); 1328 1329 sprintf(buffer, "%jd", value); 1323 1330 return buffer; 1324 1331 #endif … … 1502 1509 1503 1510 case Tint64: 1504 buf->printf("% lldL", v);1511 buf->printf("%jdL", v); 1505 1512 break; 1506 1513 1507 1514 case Tuns64: 1508 buf->printf("% lluLU", v);1515 buf->printf("%juLU", v); 1509 1516 break; 1510 1517 … … 1535 1542 } 1536 1543 else if (v & 0x8000000000000000LL) 1537 buf->printf("0x% llx", v);1544 buf->printf("0x%jx", v); 1538 1545 else 1539 buf->printf("% lld", v);1546 buf->printf("%jd", v); 1540 1547 } 1541 1548 … … 1543 1550 { 1544 1551 if ((sinteger_t)value < 0) 1545 buf->printf("N% lld", -value);1552 buf->printf("N%jd", -value); 1546 1553 else 1547 buf->printf("% lld", value);1554 buf->printf("%jd", value); 1548 1555 } 1549 1556 … … 1618 1625 int RealEquals(real_t x1, real_t x2) 1619 1626 { 1627 #if __APPLE__ 1628 return (__inline_isnan(x1) && __inline_isnan(x2)) || 1629 #else 1620 1630 return // special case nans 1621 1631 (isnan(x1) && isnan(x2)) || 1632 #endif 1622 1633 // and zero, in order to distinguish +0 from -0 1623 1634 (x1 == 0 && x2 == 0 && 1./x1 == 1./x2) || … … 1724 1735 */ 1725 1736 1737 #if __APPLE__ 1738 if (__inline_isnan(value)) 1739 #else 1726 1740 if (isnan(value)) 1741 #endif 1727 1742 buf->writestring("NAN"); // no -NAN bugs 1728 1743 else … … 3860 3875 VarDeclaration *v = var->isVarDeclaration(); 3861 3876 if (v) 3862 { 3863 v->checkNestedReference(sc, loc); 3864 } 3877 v->checkNestedReference(sc, loc); 3865 3878 return this; 3866 3879 } … … 7230 7243 else 7231 7244 { 7232 error("string slice [% llu .. %llu] is out of bounds", i1, i2);7245 error("string slice [%ju .. %ju] is out of bounds", i1, i2); 7233 7246 e = e1; 7234 7247 } … … 7236 7249 } 7237 7250 7238 type = t->nextOf()->arrayOf(); 7251 if (t->ty == Tarray) 7252 type = e1->type; 7253 else 7254 type = t->nextOf()->arrayOf(); 7239 7255 return e; 7240 7256 … … 7611 7627 else 7612 7628 { 7613 error("array index [%llu] is outside array bounds [0 .. %"PRIuSIZE"]",7614 index, length);7615 e = e1;7629 error("array index [%ju] is outside array bounds [0 .. %zu]", 7630 index, length); 7631 e = e1; 7616 7632 } 7617 7633 break; dmd/expression.h
r876 r1103 79 79 FuncDeclaration *hasThis(Scope *sc); 80 80 Expression *fromConstInitializer(int result, Expression *e); 81 int arrayExpressionCanThrow(Expressions *exps); 81 82 82 83 struct Expression : Object … … 98 99 virtual void dump(int indent); 99 100 void error(const char *format, ...); 101 void warning(const char *format, ...); 100 102 virtual void rvalue(); 101 103 dmd/func.c
r957 r1103 338 338 339 339 #if DMDV2 340 if (!isOverride() && global.params.warnings)341 warning( "%s: overrides base class function %s, but is not marked with 'override'", locToChars()fdv->toPrettyChars());340 if (!isOverride()) 341 warning(loc, "overrides base class function %s, but is not marked with 'override'", fdv->toPrettyChars()); 342 342 #endif 343 343 … … 1084 1084 { Expression *e; 1085 1085 1086 if (global.params.warnings) 1087 { warning("%s: no return at end of function", locToChars()); 1088 } 1086 warning(loc, "no return at end of function"); 1089 1087 1090 1088 if (global.params.useAssert && … … 1096 1094 endloc, 1097 1095 new IntegerExp(0), 1098 new StringExp(loc, "missing return expression")1096 new StringExp(loc, (char *)"missing return expression") 1099 1097 ); 1100 1098 } … … 2166 2164 : FuncDeclaration(loc, endloc, NULL, STCundefined, type) 2167 2165 { 2168 c har *id;2166 const char *id; 2169 2167 2170 2168 if (fes) … … 2311 2309 char *CtorDeclaration::toChars() 2312 2310 { 2313 return "this";2311 return (char *)"this"; 2314 2312 } 2315 2313 … … 2653 2651 if (!ad) 2654 2652 { 2655 error("invariants only arefor struct/union/class definitions");2653 error("invariants are only for struct/union/class definitions"); 2656 2654 return; 2657 2655 } dmd/hdrgen.c
r571 r1103 25 25 #endif 26 26 27 #if IN_GCC || IN_LLVM 28 #include "mem.h" 29 #else 30 #if _WIN32 31 #include "..\root\mem.h" 32 #elif POSIX 33 #include "../root/mem.h" 34 #else 35 #error "fix this" 36 #endif 37 #endif 27 #include "rmem.h" 38 28 39 29 #include "id.h" dmd/identifier.c
r817 r1103 94 94 95 95 buf.writestring(prefix); 96 buf.printf("% "PRIuSIZE, i);96 buf.printf("%zu", i); 97 97 98 98 char *id = buf.toChars(); dmd/interpret.c
r913 r1103 13 13 #include <assert.h> 14 14 15 #include " mem.h"15 #include "rmem.h" 16 16 17 17 #include "statement.h" … … 81 81 { 82 82 semantic3(scope); 83 if (global.errors)// if errors compiling this function84 return NULL;83 if (global.errors) // if errors compiling this function 84 return NULL; 85 85 } 86 86 if (semanticRun < 2) dmd/lexer.c
r872 r1103 21 21 #include <stdlib.h> 22 22 #include <assert.h> 23 #include <math.h> 24 25 #if _MSC_VER 26 #include <time.h> 27 #else 23 28 #include <sys/time.h> 24 # include <math.h>29 #endif 25 30 26 31 #ifdef IN_GCC 27 28 32 #include <time.h> 29 #include "mem.h" 30 31 #else 32 33 #if __GNUC__ 33 #elif __GNUC__ 34 34 #include <time.h> 35 35 #endif 36 36 37 #if IN_LLVM 38 #include "mem.h" 39 #elif _WIN32 40 #include "..\root\mem.h" 41 #else 42 #include "../root/mem.h" 43 #endif 44 #endif 37 #include "rmem.h" 45 38 46 39 #include "stringtable.h" … … 55 48 // from \dm\src\include\setlocal.h 56 49 extern "C" char * __cdecl __locale_decpoint; 50 #endif 51 52 #if _MSC_VER // workaround VC++ bug, labels and types should be in separate namespaces 53 #define Lstring Lstr 57 54 #endif 58 55 … … 141 138 142 139 case TOKint64v: 143 sprintf(buffer,"% lldL",(long long)int64value);140 sprintf(buffer,"%jdL",int64value); 144 141 break; 145 142 146 143 case TOKuns64v: 147 sprintf(buffer,"% lluUL",(unsigned long long)uns64value);144 sprintf(buffer,"%juUL",uns64value); 148 145 break; 149 146 dmd/lstring.c
r1 r1103 12 12 13 13 #include "dchar.h" 14 #include " mem.h"14 #include "rmem.h" 15 15 #include "lstring.h" 16 16 dmd/macro.c
r571 r1103 17 17 #include <assert.h> 18 18 19 #if IN_GCC || IN_LLVM 20 #include "mem.h" 21 #else 22 #if _WIN32 23 #include "..\root\mem.h" 24 #elif POSIX 25 #include "../root/mem.h" 26 #else 27 #error "fix this" 28 #endif 29 #endif 30 19 #include "rmem.h" 31 20 #include "root.h" 21 32 22 #include "macro.h" 33 23 dmd/man.c
r879 r1103 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 2008-200 8by Digital Mars3 // Copyright (c) 2008-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 42 42 browser = strdup(browser); 43 43 else 44 browser = " firefox";44 browser = "x-www-browser"; 45 45 46 46 args[0] = browser; … … 99 99 100 100 101 #if __FreeBSD__ 102 #endif dmd/mangle.c
r723 r1103 24 24 #include "id.h" 25 25 #include "module.h" 26 27 #if TARGET_LINUX || TARGET_OSX 28 char *cpp_mangle(Dsymbol *s); 29 #endif 26 30 27 31 char *mangle(Declaration *sthis) … … 111 115 case LINKwindows: 112 116 case LINKpascal: 117 return ident->toChars(); 118 113 119 case LINKcpp: 120 #if V2 && (TARGET_LINUX || TARGET_OSX) 121 return cpp_mangle(this); 122 #else 123 // Windows C++ mangling is done by C++ back end 114 124 return ident->toChars(); 125 #endif 115 126 116 127 case LINKdefault: … … 143 154 { 144 155 if (isMain()) 145 return "_Dmain";156 return (char *)"_Dmain"; 146 157 147 158 if (isWinMain() || isDllMain()) … … 217 228 buf.writestring(p); 218 229 } 219 buf.printf("% "PRIuSIZE"%s", strlen(id), id);230 buf.printf("%zu%s", strlen(id), id); 220 231 id = buf.toChars(); 221 232 buf.data = NULL; … … 244 255 buf.writestring(p); 245 256 } 246 buf.printf("% "PRIuSIZE"%s", strlen(id), id);257 buf.printf("%zu%s", strlen(id), id); 247 258 id = buf.toChars(); 248 259 buf.data = NULL; … … 270 281 buf.writestring(p); 271 282 } 272 buf.printf("% "PRIuSIZE"%s", strlen(id), id);283 buf.printf("%zu%s", strlen(id), id); 273 284 id = buf.toChars(); 274 285 buf.data = NULL; dmd/mars.c
r1064 r1103 26 26 #endif 27 27 28 #include " mem.h"28 #include "rmem.h" 29 29 #include "root.h" 30 30 … … 104 104 verror(loc, format, ap); 105 105 va_end( ap ); 106 } 107 108 void warning(Loc loc, const char *format, ...) 109 { 110 if (global.params.warnings && !global.gag) 111 { 112 fprintf(stdmsg, "warning - "); 113 va_list ap; 114 va_start(ap, format); 115 char* p = loc.toChars(); 116 fprintf(stdmsg, "Warning: %s:", p?p:""); 117 vfprintf(stdmsg, format, ap); 118 va_end( ap ); 119 } 106 120 } 107 121 dmd/mars.h
r1064 r1103 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 7by Digital Mars3 // Copyright (c) 1999-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 14 14 #ifdef __DMC__ 15 15 #pragma once 16 #endif /* __DMC__ */ 16 #endif 17 18 /* 19 It is very important to use version control macros correctly - the 20 idea is that host and target are independent. If these are done 21 correctly, cross compilers can be built. 22 The host compiler and host operating system are also different, 23 and are predefined by the host compiler. The ones used in 24 dmd are: 25 26 Macros defined by the compiler, not the code: 27 28 Compiler: 29 __DMC__ Digital Mars compiler 30 _MSC_VER Microsoft compiler 31 __GNUC__ Gnu compiler 32 33 Host operating system: 34 _WIN32 Microsoft NT, Windows 95, Windows 98, Win32s, 35 Windows 2000, Win XP, Vista 36 _WIN64 Windows for AMD64 37 linux Linux 38 __APPLE__ Mac OSX 39 40 For the target systems, there are the target operating system and 41 the target object file format: 42 43 Target operating system: 44 TARGET_WINDOS Covers 32 bit windows and 64 bit windows 45 TARGET_LINUX Covers 32 and 64 bit linux 46 TARGET_OSX Covers 32 and 64 bit Mac OSX 47 48 It is expected that the compiler for each platform will be able 49 to generate 32 and 64 bit code from the same compiler binary. 50 51 Target object module format: 52 OMFOBJ Intel Object Module Format, used on Windows 53 ELFOBJ Elf Object Module Format, used on linux 54 MACHOBJ Mach-O Object Module Format, used on Mac OSX 55 56 There are currently no macros for byte endianness order. 57 */ 58 17 59 18 60 #include <stdint.h> … … 36 78 #define DMDV2 0 // Version 2.0 features 37 79 #define BREAKABI 1 // 0 if not ready to break the ABI just yet 80 #define STRUCTTHISREF V2 // if 'this' for struct is a reference, not a pointer 81 82 /* Other targets are TARGET_LINUX and TARGET_OSX, which are 83 * set on the command line via the compiler makefile. 84 */ 85 86 #if _WIN32 87 #define TARGET_WINDOS 1 // Windows dmd generates Windows targets 88 #define OMFOBJ 1 89 #endif 90 91 #if TARGET_LINUX 92 #ifndef ELFOBJ 93 #define ELFOBJ 1 94 #endif 95 #endif 96 97 #if TARGET_OSX 98 #ifndef MACHOBJ 99 #define MACHOBJ 1 100 #endif 101 #endif 102 38 103 39 104 struct Array; … … 91 156 bool warnings; // enable warnings 92 157 char Dversion; // D version number 158 char safe; // enforce safe memory model 93 159 94 160 char *argv0; // program name … … 118 184 Array *debuglibnames; // default libraries for debug builds 119 185 120 c har *xmlname;// filename for XML output186 const char *xmlname; // filename for XML output 121 187 122 188 // Hidden debug switches … … 157 223 struct Global 158 224 { 159 c har *mars_ext;160 c har *sym_ext;161 c har *obj_ext;225 const char *mars_ext; 226 const char *sym_ext; 227 const char *obj_ext; 162 228 #if _WIN32 163 229 char *obj_ext_alt; … … 166 232 char *bc_ext; 167 233 char *s_ext; 168 char *doc_ext; // for Ddoc generated files 169 char *ddoc_ext; // for Ddoc macro include files 170 char *hdr_ext; // for D 'header' import files 171 char *copyright; 172 char *written; 234 const char *lib_ext; 235 const char *doc_ext; // for Ddoc generated files 236 const char *ddoc_ext; // for Ddoc macro include files 237 const char *hdr_ext; // for D 'header' import files 238 const char *copyright; 239 const char *written; 173 240 Array *path; // Array of char*'s which form the import lookup path 174 241 Array *filePath; // Array of char*'s which form the file import lookup path 175 242 int structalign; 176 c har *version;243 const char *version; 177 244 char *ldc_version; 178 245 char *llvm_version; … … 252 319 #endif 253 320 254 // taken from GDC255 // for handling printf incompatibilities256 #if __MSVCRT__257 #define PRIuSIZE "Iu"258 #define PRIxSIZE "Ix"259 #elif __MINGW32__260 #define PRIuSIZE "u"261 #define PRIxSIZE "x"262 #else263 #define PRIuSIZE "zu"264 #define PRIxSIZE "zx"265 #endif266 267 321 struct Module; 268 322 … … 334 388 }; 335 389 390 void warning(Loc loc, const char *format, ...); 336 391 void error(Loc loc, const char *format, ...); 337 392 void verror(Loc loc, const char *format, va_list); dmd/mem.c
r269 r1103 8 8 #include <cassert> 9 9 10 #include " mem.h"10 #include "rmem.h" 11 11 12 12 #if USE_BOEHM_GC dmd/module.c
r986 r1103 25 25 #endif 26 26 27 #include " mem.h"27 #include "rmem.h" 28 28 29 29 #include "mars.h" … … 89 89 strictlyneedmoduleinfo = 0; 90 90 #endif 91 selfimports = 0; 91 92 insearch = 0; 92 93 searchCacheIdent = NULL; … … 146 147 } 147 148 148 File* Module::buildFilePath(c har* forcename, char* path,char* ext)149 { 150 c har *argobj;149 File* Module::buildFilePath(const char* forcename, const char* path, const char* ext) 150 { 151 const char *argobj; 151 152 if (forcename) 152 153 argobj = forcename; … … 161 162 { 162 163 if(md) 163 argobj = FileName::replaceName( argobj, md->toChars());164 argobj = FileName::replaceName((char*)argobj, md->toChars()); 164 165 else 165 argobj = FileName::replaceName( argobj, toChars());166 argobj = FileName::replaceName((char*)argobj, toChars()); 166 167 167 168 // add ext, otherwise forceExt will make nested.module into nested.bc … … 927 928 mi->insearch = 1; 928 929 int r = mi->imports(m); 929 mi->insearch = 0;930 930 if (r) 931 931 return r; … … 934 934 return FALSE; 935 935 } 936 937 /************************************* 938 * Return !=0 if module imports itself. 939 */ 940 941 int Module::selfImports() 942 { 943 //printf("Module::selfImports() %s\n", toChars()); 944 if (!selfimports) 945 { 946 for (int i = 0; i < amodules.dim; i++) 947 { Module *mi = (Module *)amodules.data[i]; 948 //printf("\t[%d] %s\n", i, mi->toChars()); 949 mi->insearch = 0; 950 } 951 952 selfimports = imports(this) + 1; 953 954 for (int i = 0; i < amodules.dim; i++) 955 { Module *mi = (Module *)amodules.data[i]; 956 //printf("\t[%d] %s\n", i, mi->toChars()); 957 mi->insearch = 0; 958 } 959 } 960 return selfimports - 1; 961 } 962 936 963 937 964 /* =========================== ModuleDeclaration ===================== */ dmd/module.h
r1052 r1103 80 80 int strictlyneedmoduleinfo; 81 81 #endif 82 83 int selfimports; // 0: don't know, 1: does not, 2: does 84 int selfImports(); // returns !=0 if module imports itself 82 85 83 86 int insearch; … … 174 177 llvm::Module* genLLVMModule(int multiobj); 175 178 void buildTargetFiles(); 176 File* buildFilePath(c har* forcename, char* path,char* ext);179 File* buildFilePath(const char* forcename, const char* path, const char* ext); 177 180 Module *isModule() { return this; } 178 181 dmd/mtype.c
r1051 r1103 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 8by Digital Mars3 // Copyright (c) 1999-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 50 50 #endif 51 51 52 #include " mem.h"52 #include "rmem.h" 53 53 54 54 #include "dsymbol.h" … … 214 214 mangleChar[Ttuple] = 'B'; 215 215 mangleChar[Tslice] = '@'; 216 mangleChar[Treturn] = '@'; 216 217 217 218 for (i = 0; i < TMAX; i++) … … 710 711 } 711 712 713 void Type::warning(Loc loc, const char *format, ...) 714 { 715 if (global.params.warnings && !global.gag) 716 { 717 fprintf(stdmsg, "warning - "); 718 va_list ap; 719 va_start(ap, format); 720 ::verror(loc, format, ap); 721 va_end( ap ); 722 } 723 } 724 712 725 Identifier *Type::getTypeInfoIdent(int internal) 713 726 { … … 722 735 { buf.writeByte(mangleChar[ty]); 723 736 if (ty == Tarray) 724 buf.writeByte(mangleChar[ next->ty]);737 buf.writeByte(mangleChar[((TypeArray *)this)->next->ty]); 725 738 } 726 739 else … … 747 760 void Type::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps) 748 761 { 749 Type *t; 750 751 t = semantic(loc, sc); 762 //printf("Type::resolve() %s, %d\n", toChars(), ty); 763 Type *t = semantic(loc, sc); 752 764 *pt = t; 753 765 *pe = NULL; … … 1874 1886 1875 1887 dim = dim->optimize(WANTvalue | WANTinterpret); 1876 if (sc ->parameterSpecialization && dim->op == TOKvar &&1888 if (sc && sc->parameterSpecialization && dim->op == TOKvar && 1877 1889 ((VarExp *)dim)->var->storage_class & STCtemplateparameter) 1878 1890 { … … 1910 1922 { 1911 1923 Loverflow: 1912 error(loc, "index % lld overflow for static array", d1);1924 error(loc, "index %jd overflow for static array", d1); 1913 1925 dim = new IntegerExp(0, 1, tsize_t); 1914 1926 } … … 1924 1936 1925 1937 if (d >= tt->arguments->dim) 1926 { error(loc, "tuple index % llu exceeds %u", d, tt->arguments->dim);1938 { error(loc, "tuple index %ju exceeds %u", d, tt->arguments->dim); 1927 1939 return Type::terror; 1928 1940 } … … 1945 1957 buf->writeByte(mangleChar[ty]); 1946 1958 if (dim) 1947 buf->printf("% llu", dim->toInteger());1959 buf->printf("%ju", dim->toInteger()); 1948 1960 if (next) 1949 1961 next->toDecoBuffer(buf); … … 2637 2649 printf("TypeReference::defaultInit() '%s'\n", toChars()); 2638 2650 #endif 2639 Expression *e; 2640 e = new NullExp(loc); 2651 Expression *e = new NullExp(loc); 2641 2652 e->type = this; 2642 2653 return e; … … 3720 3731 Type *TypeTypeof::syntaxCopy() 3721 3732 { 3733 //printf("TypeTypeof::syntaxCopy() %s\n", toChars()); 3722 3734 TypeTypeof *t; 3723 3735 … … 3955 3967 if (!s) 3956 3968 { 3957 return getProperty(e->loc, ident); 3969 if (ident == Id::max || 3970 ident == Id::min || 3971 ident == Id::init || 3972 ident == Id::stringof || 3973 !sym->memtype 3974 ) 3975 { 3976 return getProperty(e->loc, ident); 3977 } 3978 return sym->memtype->dotExp(sc, e, ident); 3958 3979 } 3959 3980 m = s->isEnumMember(); … … 5039 5060 //printf("TypeTuple(this = %p)\n", this); 5040 5061 this->arguments = arguments; 5062 //printf("TypeTuple() %s\n", toChars()); 5041 5063 #ifdef DEBUG 5042 5064 if (arguments) … … 5084 5106 { 5085 5107 //printf("TypeTuple::semantic(this = %p)\n", this); 5108 //printf("TypeTuple::semantic() %s\n", toChars()); 5086 5109 if (!deco) 5087 5110 deco = merge()->deco; … … 5207 5230 5208 5231 if (!(i1 <= i2 && i2 <= tt->arguments->dim)) 5209 { error(loc, "slice [% llu..%llu] is out of range of [0..%u]", i1, i2, tt->arguments->dim);5232 { error(loc, "slice [%ju..%ju] is out of range of [0..%u]", i1, i2, tt->arguments->dim); 5210 5233 return Type::terror; 5211 5234 } … … 5252 5275 5253 5276 if (!(i1 <= i2 && i2 <= td->objects->dim)) 5254 { error(loc, "slice [% llu..%llu] is out of range of [0..%u]", i1, i2, td->objects->dim);5277 { error(loc, "slice [%ju..%ju] is out of range of [0..%u]", i1, i2, td->objects->dim); 5255 5278 goto Ldefault; 5256 5279 } dmd/mtype.h
r1051 r1103 38 38 struct Dsymbol; 39 39 struct TemplateInstance; 40 struct CppMangleState; 40 41 enum LINK; 41 42 42 43 struct TypeBasic; 43 44 struct HdrGenState; 45 struct Argument; 44 46 45 47 // Back end … … 100 102 Ttuple, 101 103 Tslice, 102 104 Treturn, 103 105 TMAX 104 106 }; … … 109 111 extern int Tptrdiff_t; 110 112 113 111 114 struct Type : Object 112 115 { 113 116 TY ty; 114 unsigned char mod; // modifiers (MODconst, MODinvariant) 117 unsigned char mod; // modifiers MODxxxx 118 /* pick this order of numbers so switch statements work better 119 */ 115 120 #define MODconst 1 // type is const 116 #define MODinvariant 2// type is invariant117 Type *next; 121 #define MODinvariant 4 // type is invariant 122 #define MODshared 2 // type is shared 118 123 char *deco; 119 124 Type *pto; // merged pointer to this type … … 243 248 virtual Expression *toExpression(); 244 249 virtual int hasPointers(); 250 Type *next; 245 251 Type *nextOf() { return next; } 246 252 247 253 static void error(Loc loc, const char *format, ...); 254 static void warning(Loc loc, const char *format, ...); 248 255 249 256 // For backend dmd/opover.c
r875 r1103 19 19 #endif 20 20 21 #if IN_GCC || IN_LLVM 22 #include "mem.h" 23 #elif POSIX 24 #include "../root/mem.h" 25 #elif _WIN32 26 #include "..\root\mem.h" 27 #endif 21 #include "rmem.h" 28 22 29 23 //#include "port.h" … … 277 271 } 278 272 } 279 273 280 274 lastf = m.lastf; 281 275 … … 577 571 { 578 572 fd = s->isFuncDeclaration(); 579 if (fd) 573 if (fd) 580 574 inferApplyArgTypesX(fd, arguments); 581 575 } dmd/optimize.c
r1025 r1103 235 235 integer_t dim = ts->dim->toInteger(); 236 236 if (index < 0 || index >= dim) 237 error("array index % lld is out of bounds [0..%lld]", index, dim);237 error("array index %jd is out of bounds [0..%jd]", index, dim); 238 238 e = new SymOffExp(loc, ve->var, index * ts->next->size()); 239 239 e->type = type; … … 422 422 d_uns64 sz = e1->type->size() * 8; 423 423 if (i2 < 0 || i2 > sz) 424 { 425 error("shift assign by %lld is outside the range 0..%"PRIuSIZE, i2, sz); 424 { error("shift assign by %jd is outside the range 0..%zu", i2, sz); 426 425 e2 = new IntegerExp(0); 427 426 } … … 518 517 d_uns64 sz = e->e1->type->size() * 8; 519 518 if (i2 < 0 || i2 > sz) 520 { 521 error("shift by %lld is outside the range 0..%"PRIuSIZE, i2, sz); 519 { e->error("shift by %jd is outside the range 0..%zu", i2, sz); 522 520 e->e2 = new IntegerExp(0); 523 521 } dmd/parse.c
r846 r1103 14 14 #include <assert.h> 15 15 16 #include " mem.h"16 #include "rmem.h" 17 17 #include "lexer.h" 18 18 #include "parse.h" dmd/root.c
r872 r1103 1 1 2 // Copyright (c) 1999-200 6by Digital Mars2 // Copyright (c) 1999-2009 by Digital Mars 3 3 // All Rights Reserved 4 4 // written by Walter Bright … … 41 41 #include "root.h" 42 42 #include "dchar.h" 43 #include " mem.h"43 #include "rmem.h" 44 44 #include "mars.h" 45 45 … … 377 377 continue; 378 378 379 #if MACINTOSH 380 case ',': 381 #endif 379 382 #if _WIN32 380 383 case ';': … … 1345 1348 { 1346 1349 if (offset > len || offset + nbytes > len) 1347 error("Corrupt file '%s': offset x% "PRIxSIZE"off end of file",toChars(),offset);1350 error("Corrupt file '%s': offset x%zx off end of file",toChars(),offset); 1348 1351 } 1349 1352 … … 1386 1389 void OutBuffer::reserve(unsigned nbytes) 1387 1390 { 1388 //printf("OutBuffer::reserve: size = %d, offset = %d, nbytes = %d\n", size, offset, nbytes);1391 //printf("OutBuffer::reserve: size = %d, offset = %d, nbytes = %d\n", size, offset, nbytes); 1389 1392 if (size - offset < nbytes) 1390 1393 { 1391 #if defined (__x86_64__)1392 size = (offset + nbytes) * 2+2;1393 #else1394 1394 size = (offset + nbytes) * 2; 1395 #endif1396 1395 data = (unsigned char *)mem.realloc(data, size); 1397 1396 } dmd/root.h
r658 r1103 38 38 39 39 #if _MSC_VER 40 #include <float.h> // for _isnan 40 41 typedef __int64 longlong; 41 42 typedef unsigned __int64 ulonglong; dmd/scope.c
r561 r1103 258 258 sc->enclosing->search(loc, ident, NULL)) 259 259 { 260 // WTF ? 261 if (global.params.warnings) 262 fprintf(stdmsg, "warning - "); 263 error(s->loc, "array 'length' hides other 'length' name in outer scope"); 260 warning(s->loc, "array 'length' hides other 'length' name in outer scope"); 264 261 } 265 262 dmd/statement.c
r945 r1103 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 8by Digital Mars3 // Copyright (c) 1999-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 13 13 #include <assert.h> 14 14 15 #include " mem.h"15 #include "rmem.h" 16 16 17 17 #include "statement.h" … … 95 95 ::verror(loc, format, ap); 96 96 va_end( ap ); 97 } 98 99 void Statement::warning(const char *format, ...) 100 { 101 if (global.params.warnings && !global.gag) 102 { 103 fprintf(stdmsg, "warning - "); 104 va_list ap; 105 va_start(ap, format); 106 ::verror(loc, format, ap); 107 va_end( ap ); 108 } 97 109 } 98 110 … … 540 552 if (!(result & BEfallthru) && !s->comeFrom()) 541 553 { 542 if (global.params.warnings) 543 { fprintf(stdmsg, "warning - "); 544 s->error("statement is not reachable"); 545 } 554 s->warning("statement is not reachable"); 546 555 } 547 556 … … 1030 1039 if (init) 1031 1040 init = init->semantic(sc); 1041 #if 0 1032 1042 if (!condition) 1033 1043 // Use a default value 1034 1044 condition = new IntegerExp(loc, 1, Type::tboolean); 1045 #endif 1035 1046 sc->noctor++; 1036 1047 if (condition) … … 1097 1108 if (body) 1098 1109 { int r = body->blockExit(); 1099 if (r & BEbreak)1110 if (r & (BEbreak | BEgoto)) 1100 1111 result |= BEfallthru; 1101 result |= r & ~(BE break | BEcontinue);1112 result |= r & ~(BEfallthru | BEbreak | BEcontinue); 1102 1113 } 1103 1114 if (increment && increment->canThrow()) … … 1670 1681 } 1671 1682 const char *r = (op == TOKforeach_reverse) ? "R" : ""; 1672 int j = sprintf(fdname, "_aApply%s%.*s% " PRIuSIZE, r, 2, fntab[flag], dim);1683 int j = sprintf(fdname, "_aApply%s%.*s%zu", r, 2, fntab[flag], dim); 1673 1684 assert(j < sizeof(fdname)); 1674 1685 //LDC: Build arguments. … … 2324 2335 { hasNoDefault = 1; 2325 2336 2326 if (global.params.warnings) 2327 { warning("%s: switch statement has no default", loc.toChars()); 2328 } 2337 warning("switch statement has no default"); 2329 2338 2330 2339 // Generate runtime error if the default is hit … … 3931 3940 return this; 3932 3941 } 3933 3934 dmd/statement.h
r945 r1103 80 80 struct code; 81 81 82 /* How a statement exits 82 /* How a statement exits; this is returned by blockExit() 83 83 */ 84 84 enum BE … … 135 135 136 136 void error(const char *format, ...); 137 void warning(const char *format, ...); 137 138 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs); 138 139 virtual TryCatchStatement *isTryCatchStatement() { return NULL; } dmd/stringtable.c
r336 r1103 14 14 15 15 #include "root.h" 16 #include " mem.h"16 #include "rmem.h" 17 17 #include "dchar.h" 18 18 #include "lstring.h" dmd/struct.c
r1003 r1103 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 6by Digital Mars3 // Copyright (c) 1999-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 45 45 sinit = NULL; 46 46 scope = NULL; 47 #if V2 48 dtor = NULL; 49 50 ctor = NULL; 51 defaultCtor = NULL; 52 #endif 47 53 } 48 54 … … 129 135 */ 130 136 131 void AggregateDeclaration::alignmember(unsigned salign, unsigned size, unsigned *poffset) 132 { 133 //printf("salign = %d, size = %d, offset = %d\n",salign,size,*poffset); 137 void AggregateDeclaration::alignmember( 138 unsigned salign, // struct alignment that is in effect 139 unsigned size, // alignment requirement of field 140 unsigned *poffset) 141 { 142 //printf("salign = %d, size = %d, offset = %d\n",salign,size,offset); 134 143 if (salign > 1) 135 { int sa; 136 137 switch (size) 138 { case 1: 139 break; 140 case 2: 141 case_2: 142 *poffset = (*poffset + 1) & ~1; // align to word 143 break; 144 case 3: 145 case 4: 146 if (salign == 2) 147 goto case_2; 148 *poffset = (*poffset + 3) & ~3; // align to dword 149 break; 150 default: 151 *poffset = (*poffset + size - 1) & ~(size - 1); 152 break; 153 } 154 } 155 //printf("result = %d\n",*poffset); 144 { 145 assert(size != 3); 146 int sa = size; 147 if (sa == 0 || salign < sa) 148 sa = salign; 149 *poffset = (*poffset + sa - 1) & ~(sa - 1); 150 } 151 //printf("result = %d\n",offset); 156 152 } 157 153 … … 169 165 if (t->ty == Tstruct /*&& isStructDeclaration()*/) 170 166 { TypeStruct *ts = (TypeStruct *)t; 167 #if V2 168 if (ts->sym == this) 169 { 170 error("cannot have field %s with same struct type", v->toChars()); 171 } 172 #endif 171 173 172 174 if (ts->sym->sizeok != 1) … … 208 210 { 209 211 zeroInit = 0; // assume false until we do semantic processing 212 #if V2 213 hasIdentityAssign = 0; 214 cpctor = NULL; 215 postblit = NULL; 216 #endif 210 217 211 218 // For forward references … … 252 259 253 260 parent = sc->parent; 261 #if STRUCTTHISREF 262 handle = type; 263 #else 254 264 handle = type->pointerTo(); 265 #endif 255 266 structalign = sc->structalign; 256 267 protection = sc->protection; … … 260 271 if (sc->stc & STCabstract) 261 272 error("structs, unions cannot be abstract"); 273 #if V2 274 if (storage_class & STCinvariant) 275 type = type->invariantOf(); 276 else if (storage_class & STCconst) 277 type = type->constOf(); 278 #endif 262 279 263 280 if (sizeok == 0) // if not already done the addMember step … … 352 369 id = Id::cmp; 353 370 } 354 371 #if V2 372 dtor = buildDtor(sc2); 373 postblit = buildPostBlit(sc2); 374 cpctor = buildCpCtor(sc2); 375 buildOpAssign(sc2); 376 #endif 355 377 356 378 sc2->pop(); … … 415 437 /* Look for special member functions. 416 438 */ 439 #if V2 440 ctor = (CtorDeclaration *)search(0, Id::ctor, 0); 441 #endif 417 442 inv = (InvariantDeclaration *)search(0, Id::classInvariant, 0); 418 443 aggNew = (NewDeclaration *)search(0, Id::classNew, 0); dmd/template.c
r1089 r1103 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 8by Digital Mars3 // Copyright (c) 1999-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 22 22 23 23 #include "root.h" 24 #include " mem.h"24 #include "rmem.h" 25 25 #include "stringtable.h" 26 26 #include "mars.h" … … 187 187 goto Lnomatch; 188 188 } 189 #if V2 190 VarDeclaration *v1 = s1->isVarDeclaration(); 191 VarDeclaration *v2 = s2->isVarDeclaration(); 192 if (v1 && v2 && v1->storage_class & v2->storage_class & STCmanifest) 193 { ExpInitializer *ei1 = v1->init->isExpInitializer(); 194 ExpInitializer *ei2 = v2->init->isExpInitializer(); 195 if (ei1 && ei2 && !ei1->exp->equals(ei2->exp)) 196 goto Lnomatch; 197 } 198 #endif 189 199 } 190 200 else if (v1) … … 254 264 } 255 265 266 #if V2 267 Object *objectSyntaxCopy(Object *o) 268 { 269 if (!o) 270 return NULL; 271 Type *t = isType(o); 272 if (t) 273 return t->syntaxCopy(); 274 Expression *e = isExpression(o); 275 if (e) 276 return e->syntaxCopy(); 277 return o; 278 } 279 #endif 256 280 257 281 … … 280 304 this->parameters = parameters; 281 305 this->origParameters = parameters; 306 #if V2 307 this->constraint = constraint; 308 #endif 282 309 this->members = decldefs; 283 310 this->overnext = NULL; … … 304 331 } 305 332 } 333 #if V2 334 Expression *e = NULL; 335 if (constraint) 336 e = constraint->syntaxCopy(); 337 #endif 306 338 d = Dsymbol::arraySyntaxCopy(members); 307 339 td = new TemplateDeclaration(loc, ident, p, d); … … 353 385 Scope *paramscope = sc->push(paramsym); 354 386 paramscope->parameterSpecialization = 1; 387 paramscope->stc = 0; 355 388 356 389 if (global.params.doDocComments) … … 513 546 paramsym->parent = scope->parent; 514 547 Scope *paramscope = scope->push(paramsym); 548 paramscope->stc = 0; 515 549 516 550 // Attempt type deduction … … 764 798 765 799 for (i = 0; i < nargsi; i++) 766 { TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; 800 { assert(i < parameters->dim); 801 TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; 767 802 MATCH m; 768 803 Declaration *sparam; … … 801 836 //printf("t = %p\n", t); 802 837 dedargs->data[parameters->dim - 1] = (void *)t; 838 declareParameter(paramscope, tp, t); 803 839 goto L2; 804 840 } … … 836 872 t->objects.data[i] = (void *)farg->type; 837 873 } 874 declareParameter(paramscope, tp, t); 838 875 goto L2; 839 876 } … … 1021 1058 Declaration *sparam; 1022 1059 dedargs->data[i] = (void *)oded; 1023 MATCH m2 = tp->matchArg(paramscope, dedargs, i, parameters, &dedtypes, &sparam );1060 MATCH m2 = tp->matchArg(paramscope, dedargs, i, parameters, &dedtypes, &sparam, 0); 1024 1061 //printf("m2 = %d\n", m2); 1025 1062 if (!m2) … … 1078 1115 1079 1116 /************************************************** 1080 * Declare template parameter tp with value o .1117 * Declare template parameter tp with value o, and install it in the scope sc. 1081 1118 */ 1082 1119 … … 1261 1298 if (td_ambig) 1262 1299 { 1263 error(loc, " %s matches more than one function template declaration, %s and%s",1264 t oChars(), td_best->toChars(), td_ambig->toChars());1300 error(loc, "matches more than one function template declaration:\n %s\nand:\n %s", 1301 td_best->toChars(), td_ambig->toChars()); 1265 1302 } 1266 1303 … … 1795 1832 Expression *e2 = isExpression(o2); 1796 1833 1834 Dsymbol *s1 = isDsymbol(o1); 1835 Dsymbol *s2 = isDsymbol(o2); 1836 1837 Tuple *v1 = isTuple(o1); 1838 Tuple *v2 = isTuple(o2); 1797 1839 #if 0 1798 1840 if (t1) printf("t1 = %s\n", t1->toChars()); … … 1800 1842 if (e1) printf("e1 = %s\n", e1->toChars()); 1801 1843 if (e2) printf("e2 = %s\n", e2->toChars()); 1844 if (s1) printf("s1 = %s\n", s1->toChars()); 1845 if (s2) printf("s2 = %s\n", s2->toChars()); 1846 if (v1) printf("v1 = %s\n", v1->toChars()); 1847 if (v2) printf("v2 = %s\n", v2->toChars()); 1802 1848 #endif 1803 1849 … … 1846 1892 } 1847 1893 } 1848 // BUG: Need to handle alias and tuple parameters 1894 else if (s1 && t2 && t2->ty == Tident) 1895 { 1896 j = templateParameterLookup(t2, parameters); 1897 if (j == -1) 1898 goto Lnomatch; 1899 TemplateParameter *tp = (TemplateParameter *)parameters->data[j]; 1900 // BUG: use tp->matchArg() instead of the following 1901 TemplateAliasParameter *ta = tp->isTemplateAliasParameter(); 1902 if (!ta) 1903 goto Lnomatch; 1904 Dsymbol *s = (Dsymbol *)dedtypes->data[j]; 1905 if (s) 1906 { 1907 if (!s1->equals(s)) 1908 goto Lnomatch; 1909 } 1910 else 1911 { 1912 dedtypes->data[j] = s1; 1913 } 1914 } 1915 else if (s1 && s2) 1916 { 1917 if (!s1->equals(s2)) 1918 goto Lnomatch; 1919 } 1920 // BUG: Need to handle tuple parameters 1849 1921 else 1850 1922 goto Lnomatch; … … 2114 2186 MATCH TemplateTypeParameter::matchArg(Scope *sc, Objects *tiargs, 2115 2187 int i, TemplateParameters *parameters, Objects *dedtypes, 2116 Declaration **psparam )2188 Declaration **psparam, int flags) 2117 2189 { 2118 2190 //printf("TemplateTypeParameter::matchArg()\n"); … … 2358 2430 MATCH TemplateAliasParameter::matchArg(Scope *sc, 2359 2431 Objects *tiargs, int i, TemplateParameters *parameters, Objects *dedtypes, 2360 Declaration **psparam )2432 Declaration **psparam, int flags) 2361 2433 { 2362 2434 Dsymbol *sa; … … 2570 2642 MATCH TemplateValueParameter::matchArg(Scope *sc, 2571 2643 Objects *tiargs, int i, TemplateParameters *parameters, Objects *dedtypes, 2572 Declaration **psparam )2644 Declaration **psparam, int flags) 2573 2645 { 2574 2646 //printf("TemplateValueParameter::matchArg()\n"); … … 2767 2839 Objects *tiargs, int i, TemplateParameters *parameters, 2768 2840 Objects *dedtypes, 2769 Declaration **psparam )2841 Declaration **psparam, int flags) 2770 2842 { 2771 2843 //printf("TemplateTupleParameter::matchArg()\n"); … … 3027 3099 } 3028 3100 3029 isNested(tiargs);3101 hasNestedArgs(tiargs); 3030 3102 3031 3103 /* See if there is an existing TemplateInstantiation that already … … 3102 3174 //if (scx && scx->scopesym) printf("3: scx is %s %s\n", scx->scopesym->kind(), scx->scopesym->toChars()); 3103 3175 if (scx && scx->scopesym && 3104 scx->scopesym->members && !scx->scopesym->isTemplateMixin() && 3105 /* The following test should really be if scx->module recursively 3106 * imports itself. Because if it does, see bugzilla 2500. 3176 scx->scopesym->members && !scx->scopesym->isTemplateMixin() 3177 #if 1 // removed because it bloated compile times 3178 /* The problem is if A imports B, and B imports A, and both A 3179 * and B instantiate the same template, does the compilation of A 3180 * or the compilation of B do the actual instantiation? 3181 * 3182 * see bugzilla 2500. 3107 3183 */ 3108 //scx->module == tempdecl->getModule()3109 !scx->module->imports(scx->module) 3184 && !scx->module->selfImports() 3185 #endif 3110 3186 ) 3111 3187 { … … 3152 3228 3153 3229 // Declare each template parameter as an alias for the argument type 3154 declareParameters(scope); 3230 Scope *paramscope = scope->push(); 3231 paramscope->stc = 0; 3232 declareParameters(paramscope); 3233 paramscope->pop(); 3155 3234 3156 3235 // Add members of template instance to template instance symbol table … … 3621 3700 */ 3622 3701 3623 int TemplateInstance:: isNested(Objects *args)3702 int TemplateInstance::hasNestedArgs(Objects *args) 3624 3703 { int nested = 0; 3625 //printf("TemplateInstance:: isNested('%s')\n", tempdecl->ident->toChars());3704 //printf("TemplateInstance::hasNestedArgs('%s')\n", tempdecl->ident->toChars()); 3626 3705 3627 3706 /* A nested instance happens when an argument references a local … … 3692 3771 else if (va) 3693 3772 { 3694 nested |= isNested(&va->objects);3773 nested |= hasNestedArgs(&va->objects); 3695 3774 } 3696 3775 } … … 3711 3790 //printf("TemplateInstance::genIdent('%s')\n", tempdecl->ident->toChars()); 3712 3791 id = tempdecl->ident->toChars(); 3713 buf.printf("__T% "PRIuSIZE"%s", strlen(id), id);3792 buf.printf("__T%zu%s", strlen(id), id); 3714 3793 args = tiargs; 3715 3794 for (int i = 0; i < args->dim; i++) … … 3778 3857 { 3779 3858 char *p = sa->mangle(); 3780 buf.printf("%"PRIuSIZE"%s", strlen(p), p);3859 buf.printf("%zu%s", strlen(p), p); 3781 3860 } 3782 3861 } dmd/template.h
r1067 r1103 1 1 2 2 // Compiler implementation of the D programming language 3 // Copyright (c) 1999-200 8by Digital Mars3 // Copyright (c) 1999-2009 by Digital Mars 4 4 // All Rights Reserved 5 5 // written by Walter Bright … … 138 138 /* Match actual argument against parameter. 139 139 */ 140 virtual MATCH matchArg(Scope *sc, Objects *tiargs, int i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam ) = 0;140 virtual MATCH matchArg(Scope *sc, Objects *tiargs, int i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags = 0) = 0; 141 141 142 142 /* Create dummy argument based on parameter. … … 164 164 Object *defaultArg(Loc loc, Scope *sc); 165 165 int overloadMatch(TemplateParameter *); 166 MATCH matchArg(Scope *sc, Objects *tiargs, int i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam );166 MATCH matchArg(Scope *sc, Objects *tiargs, int i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags); 167 167 void *dummyArg(); 168 168 }; … … 208 208 Object *defaultArg(Loc loc, Scope *sc); 209 209 int overloadMatch(TemplateParameter *); 210 MATCH matchArg(Scope *sc, Objects *tiargs, int i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam );210 MATCH matchArg(Scope *sc, Objects *tiargs, int i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags); 211 211 void *dummyArg(); 212 212 }; … … 236 236 Object *defaultArg(Loc loc, Scope *sc); 237 237 int overloadMatch(TemplateParameter *); 238 MATCH matchArg(Scope *sc, Objects *tiargs, int i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam );238 MATCH matchArg(Scope *sc, Objects *tiargs, int i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags); 239 239 void *dummyArg(); 240 240 }; … … 257 257 Object *defaultArg(Loc loc, Scope *sc); 258 258 int overloadMatch(TemplateParameter *); 259 MATCH matchArg(Scope *sc, Objects *tiargs, int i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam );259 MATCH matchArg(Scope *sc, Objects *tiargs, int i, TemplateParameters *parameters, Objects *dedtypes, Declaration **psparam, int flags); 260 260 void *dummyArg(); 261 261 }; … … 319 319 TemplateDeclaration *findBestMatch(Scope *sc); 320 320 void declareParameters(Scope *sc); 321 int isNested(Objects *tiargs);321 int hasNestedArgs(Objects *tiargs); 322 322 Identifier *genIdent(); 323 323 gen/asmstmt.cpp
r1102 r1103 470 470 size_t pos = insnt.find(needle); 471 471 if(std::string::npos != pos) 472 sprintf(buf, "% " PRIuSIZE, idx++);472 sprintf(buf, "%lu", idx++); 473 473 while(std::string::npos != (pos = insnt.find(needle))) 474 474 insnt.replace(pos, needle.size(), buf); … … 495 495 size_t pos = insnt.find(needle); 496 496 if(std::string::npos != pos) 497 sprintf(buf, "% " PRIuSIZE, idx++);497 sprintf(buf, "%lu", idx++); 498 498 while(std::string::npos != (pos = insnt.find(needle))) 499 499 insnt.replace(pos, needle.size(), buf); gen/cl_helpers.cpp
r1063 r1103 2 2 3 3 #include "root.h" 4 #include " mem.h"4 #include "rmem.h" 5 5 6 6 #include <cctype> // isupper, tolower gen/main.cpp
r1073 r1103 22 22 #endif 23 23 24 #include " mem.h"24 #include "rmem.h" 25 25 #include "root.h" 26 26 … … 39 39 #include "gen/cl_helpers.h" 40 40 using namespace opts; 41 42 #include "gen/configfile.h" 41 43 42 44 extern void getenv_setargv(const char *envvar, int *pargc, char** *pargv); … … 145 147 #endif 146 148 147 148 // read the inifile 149 #if DMDV2 150 inifile(global.params.argv0, "ldc2.conf"); 151 #else 152 inifile(global.params.argv0, "ldc.conf"); 153 #endif 154 155 // merge DFLAGS into argc/argv 149 // merge DFLAGS environment variable into argc/argv 156 150 getenv_setargv("DFLAGS", &argc, &argv); 157 151 #if 0 … … 162 156 #endif 163 157 158 // build complete fixed up list of command line arguments 159 std::vector<const char*> final_args; 160 final_args.reserve(argc); 161 162 // insert argc + DFLAGS 163 final_args.insert(final_args.end(), &argv[0], &argv[argc]); 164 165 // read the configuration file 166 ConfigFile cfg_file; 167 168 // just ignore errors for now, they are still printed 169 #if DMDV2 170 #define CFG_FILENAME "ldc2.conf" 171 #else 172 #define CFG_FILENAME "ldc.conf" 173 #endif 174 cfg_file.read(global.params.argv0, (void*)main, CFG_FILENAME); 175 #undef CFG_FILENAME 176 177 // insert config file additions to the argument list 178 final_args.insert(final_args.end(), cfg_file.switches_begin(), cfg_file.switches_end()); 179 180 #if 0 181 for (size_t i = 0; i < final_args.size(); ++i) 182 { 183 printf("final_args[%zu] = %s\n", i, final_args[i]); 184 } 185 #endif 186 164 187 // Handle fixed-up arguments! 165 188 cl::SetVersionPrinter(&printVersion); 166 cl::ParseCommandLineOptions( argc, argv, "LLVM-based D Compiler\n");189 cl::ParseCommandLineOptions(final_args.size(), (char**)&final_args[0], "LLVM-based D Compiler\n", true); 167 190 168 191 global.params.optimize = (global.params.optimizeLevel >= 0); gen/statements.cpp
r1051 r1103 10 10 11 11 #include "mars.h" 12 #include "total.h"13 12 #include "init.h" 14 13 #include "mtype.h" gen/toir.cpp
r1036 r1103 14 14 15 15 #include "attrib.h" 16 #include "total.h"17 16 #include "init.h" 18 17 #include "mtype.h" … … 20 19 #include "hdrgen.h" 21 20 #include "port.h" 22 #include "mem.h" 21 #include "rmem.h" 22 #include "id.h" 23 #include "enum.h" 23 24 24 25 #include "gen/irstate.h" ldc.conf.in
r986 r1103 1 [Environment] 2 DFLAGS=-I@RUNTIME_DIR@ -I@RUNTIME_DIR@/lib/common -L-L%@P%/../lib -d-version=Tango -defaultlib=@RUNTIME_AIO@ -debuglib=@RUNTIME_AIO@ 1 // This configuration file uses libconfig. 2 // See http://www.hyperrealm.com/libconfig/ for syntax details. 3 4 // The default group is required 5 default: 6 { 7 // 'switches' holds array of string that are appends to the command line 8 // arguments before they are parsed. 9 // {#} is replaced with the path to the directory holding the executable 10 switches = [ 11 "-I@RUNTIME_DIR@", 12 "-I@RUNTIME_DIR@/lib/common", 13 "-L-L@PROJECT_BINARY_DIR@/../lib", 14 "-d-version=Tango", 15 "-defaultlib=@RUNTIME_AIO@" 16 ]; 17 };

