mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-09-17 19:07:05 +02:00
Merged DMD 2.060 frontend.
Upstream Git tag v2.060 (e8fe11c20249cb9e42538be88c99b74ede4d12e3).
This commit is contained in:
+53
-26
@@ -11,6 +11,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h> // memcpy()
|
||||
|
||||
#include "rmem.h"
|
||||
|
||||
@@ -37,7 +38,7 @@
|
||||
extern void obj_includelib(const char *name);
|
||||
|
||||
#if IN_DMD
|
||||
void obj_startaddress(Symbol *s);
|
||||
bool obj_startaddress(Symbol *s);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -90,7 +91,7 @@ int AttribDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
|
||||
|
||||
void AttribDeclaration::setScopeNewSc(Scope *sc,
|
||||
StorageClass stc, enum LINK linkage, enum PROT protection, int explicitProtection,
|
||||
unsigned structalign)
|
||||
structalign_t structalign)
|
||||
{
|
||||
if (decl)
|
||||
{
|
||||
@@ -125,7 +126,7 @@ void AttribDeclaration::setScopeNewSc(Scope *sc,
|
||||
|
||||
void AttribDeclaration::semanticNewSc(Scope *sc,
|
||||
StorageClass stc, enum LINK linkage, enum PROT protection, int explicitProtection,
|
||||
unsigned structalign)
|
||||
structalign_t structalign)
|
||||
{
|
||||
if (decl)
|
||||
{
|
||||
@@ -760,7 +761,10 @@ void AlignDeclaration::semantic(Scope *sc)
|
||||
|
||||
void AlignDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
{
|
||||
buf->printf("align (%d)", salign);
|
||||
if (salign == STRUCTALIGN_DEFAULT)
|
||||
buf->printf("align");
|
||||
else
|
||||
buf->printf("align (%d)", salign);
|
||||
AttribDeclaration::toCBuffer(buf, hgs);
|
||||
}
|
||||
|
||||
@@ -938,7 +942,7 @@ void PragmaDeclaration::setScope(Scope *sc)
|
||||
{
|
||||
Expression *e = (*args)[0];
|
||||
e = e->semantic(sc);
|
||||
e = e->optimize(WANTvalue | WANTinterpret);
|
||||
e = e->ctfeInterpret();
|
||||
(*args)[0] = e;
|
||||
StringExp* se = e->toString();
|
||||
if (!se)
|
||||
@@ -977,8 +981,8 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
Expression *e = (*args)[i];
|
||||
|
||||
e = e->semantic(sc);
|
||||
if (e->op != TOKerror)
|
||||
e = e->optimize(WANTvalue | WANTinterpret);
|
||||
if (e->op != TOKerror && e->op != TOKtype)
|
||||
e = e->ctfeInterpret();
|
||||
if (e->op == TOKerror)
|
||||
{ errorSupplemental(loc, "while evaluating pragma(msg, %s)", (*args)[i]->toChars());
|
||||
return;
|
||||
@@ -1004,7 +1008,7 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
Expression *e = (*args)[0];
|
||||
|
||||
e = e->semantic(sc);
|
||||
e = e->optimize(WANTvalue | WANTinterpret);
|
||||
e = e->ctfeInterpret();
|
||||
(*args)[0] = e;
|
||||
if (e->op == TOKerror)
|
||||
goto Lnodecl;
|
||||
@@ -1022,7 +1026,7 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
}
|
||||
goto Lnodecl;
|
||||
}
|
||||
#if IN_GCC
|
||||
#ifdef IN_GCC
|
||||
else if (ident == Id::GNU_asm)
|
||||
{
|
||||
if (! args || args->dim != 2)
|
||||
@@ -1046,7 +1050,7 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
|
||||
e = (*args)[1];
|
||||
e = e->semantic(sc);
|
||||
e = e->optimize(WANTvalue | WANTinterpret);
|
||||
e = e->ctfeInterpret();
|
||||
e = e->toString();
|
||||
if (e && ((StringExp *)e)->sz == 1)
|
||||
s = ((StringExp *)e);
|
||||
@@ -1068,7 +1072,7 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
{
|
||||
Expression *e = (*args)[0];
|
||||
e = e->semantic(sc);
|
||||
e = e->optimize(WANTvalue | WANTinterpret);
|
||||
e = e->ctfeInterpret();
|
||||
(*args)[0] = e;
|
||||
Dsymbol *sa = getDsymbol(e);
|
||||
if (!sa || !sa->isFuncDeclaration())
|
||||
@@ -1105,7 +1109,7 @@ void PragmaDeclaration::semantic(Scope *sc)
|
||||
unsigned errors_save = global.errors;
|
||||
|
||||
e = e->semantic(sc);
|
||||
e = e->optimize(WANTvalue | WANTinterpret);
|
||||
e = e->ctfeInterpret();
|
||||
if (i == 0)
|
||||
printf(" (");
|
||||
else
|
||||
@@ -1175,21 +1179,19 @@ void PragmaDeclaration::toObjFile(int multiobj)
|
||||
char *name = (char *)mem.malloc(se->len + 1);
|
||||
memcpy(name, se->string, se->len);
|
||||
name[se->len] = 0;
|
||||
#if OMFOBJ
|
||||
/* The OMF format allows library names to be inserted
|
||||
* into the object file. The linker will then automatically
|
||||
|
||||
/* Embed the library names into the object file.
|
||||
* The linker will then automatically
|
||||
* search that library, too.
|
||||
*/
|
||||
obj_includelib(name);
|
||||
#elif ELFOBJ || MACHOBJ
|
||||
/* The format does not allow embedded library names,
|
||||
* so instead append the library name to the list to be passed
|
||||
* to the linker.
|
||||
*/
|
||||
global.params.libfiles->push(name);
|
||||
#else
|
||||
error("pragma lib not supported");
|
||||
#endif
|
||||
if (!obj_includelib(name))
|
||||
{
|
||||
/* The format does not allow embedded library names,
|
||||
* so instead append the library name to the list to be passed
|
||||
* to the linker.
|
||||
*/
|
||||
global.params.libfiles->push(name);
|
||||
}
|
||||
}
|
||||
#if DMDV2
|
||||
else if (ident == Id::startaddress)
|
||||
@@ -1406,6 +1408,31 @@ Dsymbol *StaticIfDeclaration::syntaxCopy(Dsymbol *s)
|
||||
return dd;
|
||||
}
|
||||
|
||||
Dsymbols *StaticIfDeclaration::include(Scope *sc, ScopeDsymbol *sd)
|
||||
{
|
||||
//printf("StaticIfDeclaration::include(sc = %p) scope = %p\n", sc, scope);
|
||||
|
||||
if (condition->inc == 0)
|
||||
{
|
||||
Dsymbols *d = ConditionalDeclaration::include(sc, sd);
|
||||
|
||||
// Set the scopes lazily.
|
||||
if (scope && d)
|
||||
{
|
||||
for (size_t i = 0; i < d->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (*d)[i];
|
||||
|
||||
s->setScope(sc);
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ConditionalDeclaration::include(sc, sd);
|
||||
}
|
||||
}
|
||||
|
||||
int StaticIfDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum)
|
||||
{
|
||||
@@ -1512,7 +1539,7 @@ void CompileDeclaration::compileIt(Scope *sc)
|
||||
//printf("CompileDeclaration::compileIt(loc = %d) %s\n", loc.linnum, exp->toChars());
|
||||
exp = exp->semantic(sc);
|
||||
exp = resolveProperties(sc, exp);
|
||||
exp = exp->optimize(WANTvalue | WANTinterpret);
|
||||
exp = exp->ctfeInterpret();
|
||||
StringExp *se = exp->toString();
|
||||
if (!se)
|
||||
{ exp->error("argument to mixin must be a string, not (%s)", exp->toChars());
|
||||
|
||||
Reference in New Issue
Block a user