Skip to content

Commit dd77f58

Browse files
committed
Merge remote-tracking branch 'origin/dmd-rewrite-stable' into merge-2.111
Conflicts: dmd/declaration.h dmd/expression.h
2 parents 892c5ed + 5041634 commit dd77f58

File tree

12 files changed

+74
-15
lines changed

12 files changed

+74
-15
lines changed

dmd/cxxfrontend.d

+26
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import dmd.astenums;
1616
import dmd.attrib;
1717
import dmd.common.outbuffer : OutBuffer;
1818
import dmd.dclass : ClassDeclaration;
19+
import dmd.declaration : TypeInfoDeclaration;
1920
import dmd.denum : EnumDeclaration;
2021
import dmd.dmodule /*: Module*/;
2122
import dmd.dscope : Scope;
@@ -277,6 +278,19 @@ bool fill(StructDeclaration sd, Loc loc,
277278
return dmd.expressionsem.fill(sd, loc, elements, ctorinit);
278279
}
279280

281+
/***********************************************************
282+
* func.d
283+
*/
284+
FuncDeclaration genCfunc(Parameters* fparams, Type treturn, const(char)* name, StorageClass stc = STC.none)
285+
{
286+
return FuncDeclaration.genCfunc(fparams, treturn, name, cast(STC) stc);
287+
}
288+
289+
FuncDeclaration genCfunc(Parameters* fparams, Type treturn, Identifier id, StorageClass stc = STC.none)
290+
{
291+
return FuncDeclaration.genCfunc(fparams, treturn, id, cast(STC) stc);
292+
}
293+
280294
/***********************************************************
281295
* funcsem.d
282296
*/
@@ -720,6 +734,18 @@ bool builtinTypeInfo(Type t)
720734
return dmd.typinf.builtinTypeInfo(t);
721735
}
722736

737+
Type makeNakedAssociativeArray(TypeAArray t)
738+
{
739+
import dmd.typinf;
740+
return dmd.typinf.makeNakedAssociativeArray(t);
741+
}
742+
743+
TypeInfoDeclaration getTypeInfoAssocArrayDeclaration(TypeAArray t, Scope* sc)
744+
{
745+
import dmd.typinf;
746+
return dmd.typinf.getTypeInfoAssocArrayDeclaration(t, sc);
747+
}
748+
723749
version (IN_LLVM)
724750
{
725751
/***********************************************************

dmd/declaration.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ namespace dmd
3737
bool checkClosure(FuncDeclaration* fd);
3838
MATCH leastAsSpecialized(FuncDeclaration *f, FuncDeclaration *g, Identifiers *names);
3939
PURE isPure(FuncDeclaration *f);
40+
FuncDeclaration *genCfunc(Parameters *args, Type *treturn, const char *name, StorageClass stc=0);
41+
FuncDeclaration *genCfunc(Parameters *args, Type *treturn, Identifier *id, StorageClass stc=0);
4042
}
4143

42-
enum class STC : uint64_t;
44+
//enum STC : ulong from astenums.d:
4345

4446
#define STCundefined 0ULL
4547

@@ -756,9 +758,6 @@ class FuncDeclaration : public Declaration
756758
bool hasNestedFrameRefs();
757759
ParameterList getParameterList();
758760

759-
static FuncDeclaration *genCfunc(Parameters *args, Type *treturn, const char *name, STC stc = (STC)0);
760-
static FuncDeclaration *genCfunc(Parameters *args, Type *treturn, Identifier *id, STC stc = (STC)0);
761-
762761
virtual FuncDeclaration *toAliasFunc() { return this; }
763762
void accept(Visitor *v) override { v->visit(this); }
764763
};

dmd/expression.h

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class OverloadSet;
4040
class StringExp;
4141
class InterpExp;
4242
class LoweredAssignExp;
43-
class EnumDeclaration;
4443
class StaticForeach;
4544
#ifdef IN_GCC
4645
typedef union tree_node Symbol;

dmd/frontend.h

+18-3
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,22 @@ enum class MessageStyle : uint8_t
377377
sarif = 2u,
378378
};
379379

380+
struct SourceLoc final
381+
{
382+
_d_dynamicArray< const char > filename;
383+
uint32_t line;
384+
uint32_t column;
385+
uint32_t fileOffset;
386+
const char* toChars(bool showColumns = Loc::showColumns, MessageStyle messageStyle = Loc::messageStyle) const;
387+
SourceLoc() :
388+
filename(),
389+
line(),
390+
column(),
391+
fileOffset()
392+
{
393+
}
394+
};
395+
380396
struct Loc final
381397
{
382398
private:
@@ -390,7 +406,8 @@ struct Loc final
390406
uint32_t linnum() const;
391407
const char* filename() const;
392408
const char* toChars(bool showColumns = Loc::showColumns, MessageStyle messageStyle = Loc::messageStyle) const;
393-
bool equals(const Loc& loc) const;
409+
SourceLoc toSourceLoc() const;
410+
bool equals(Loc loc) const;
394411
Loc() :
395412
index(0u)
396413
{
@@ -4052,8 +4069,6 @@ class FuncDeclaration : public Declaration
40524069
bool needsClosure();
40534070
bool hasNestedFrameRefs();
40544071
ParameterList getParameterList();
4055-
static FuncDeclaration* genCfunc(Array<Parameter* >* fparams, Type* treturn, const char* name, STC stc = (STC)0LLU);
4056-
static FuncDeclaration* genCfunc(Array<Parameter* >* fparams, Type* treturn, Identifier* id, STC stc = (STC)0LLU);
40574072
virtual FuncDeclaration* toAliasFunc();
40584073
void accept(Visitor* v) override;
40594074
};

dmd/func.d

+2-2
Original file line numberDiff line numberDiff line change
@@ -1058,12 +1058,12 @@ version (IN_LLVM)
10581058
/**********************************
10591059
* Generate a FuncDeclaration for a runtime library function.
10601060
*/
1061-
static FuncDeclaration genCfunc(Parameters* fparams, Type treturn, const(char)* name, STC stc = STC.none)
1061+
extern(D) static FuncDeclaration genCfunc(Parameters* fparams, Type treturn, const(char)* name, STC stc = STC.none)
10621062
{
10631063
return genCfunc(fparams, treturn, Identifier.idPool(name[0 .. strlen(name)]), stc);
10641064
}
10651065

1066-
static FuncDeclaration genCfunc(Parameters* fparams, Type treturn, Identifier id, STC stc = STC.none)
1066+
extern(D) static FuncDeclaration genCfunc(Parameters* fparams, Type treturn, Identifier id, STC stc = STC.none)
10671067
{
10681068
FuncDeclaration fd;
10691069
TypeFunction tf;

dmd/globals.h

+9
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@ typedef unsigned long long uinteger_t;
504504
#endif
505505

506506
// file location
507+
struct SourceLoc
508+
{
509+
DString filename;
510+
uint32_t line;
511+
uint32_t column;
512+
uint32_t fileOffset;
513+
};
514+
507515
struct Loc
508516
{
509517
private:
@@ -529,6 +537,7 @@ struct Loc
529537
uint32_t charnum() const;
530538
uint32_t linnum() const;
531539
const char *filename() const;
540+
SourceLoc toSourceLoc() const;
532541

533542
const char *toChars(
534543
bool showColumns = Loc::showColumns,

dmd/iasmgcc.d

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public Statement gccAsmSemantic(GccAsmStatement s, Scope* sc)
5555
*ptoklist = null;
5656
}
5757
p.token = *toklist;
58-
p.scanloc = s.loc;
58+
p.baseLoc.startLine = s.loc.linnum;
59+
p.linnum = s.loc.linnum;
5960

6061
// Parse the gcc asm statement.
6162
const errors = global.errors;

dmd/location.d

+7-1
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,20 @@ nothrow:
124124
return this.index - locFileTable[i].startIndex;
125125
}
126126

127+
/// Returns: this location as a SourceLoc
128+
extern (C++) SourceLoc toSourceLoc() const @nogc @safe
129+
{
130+
return SourceLoc(this);
131+
}
132+
127133
/**
128134
* Checks for equivalence by comparing the filename contents (not the pointer) and character location.
129135
*
130136
* Note:
131137
* - Uses case-insensitive comparison on Windows
132138
* - Ignores `charnum` if `Columns` is false.
133139
*/
134-
extern (C++) bool equals(ref const(Loc) loc) const
140+
extern (C++) bool equals(Loc loc) const
135141
{
136142
SourceLoc lhs = SourceLoc(this);
137143
SourceLoc rhs = SourceLoc(loc);

dmd/typinf.h

+4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414

1515
class Expression;
1616
class Type;
17+
class TypeAArray;
18+
class TypeInfoDeclaration;
1719
struct Scope;
1820

1921
namespace dmd
2022
{
2123
bool genTypeInfo(Expression *e, Loc loc, Type *torig, Scope *sc);
2224
bool isSpeculativeType(Type *t);
2325
bool builtinTypeInfo(Type *t);
26+
Type *makeNakedAssociativeArray(TypeAArray *t);
27+
TypeInfoDeclaration *getTypeInfoAssocArrayDeclaration(TypeAArray *t, Scope *sc);
2428
}
2529
Type *getTypeInfoType(Loc loc, Type *t, Scope *sc);

gen/trycatchfinally.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void TryCatchScope::emitCatchBodies(IRState &irs, llvm::Value *ehPtrSlot) {
112112
* exception handler. At some point should try to do better.
113113
*/
114114
FuncDeclaration *fdend =
115-
FuncDeclaration::genCfunc(nullptr, Type::tvoid, "__cxa_end_catch");
115+
dmd::genCfunc(nullptr, Type::tvoid, "__cxa_end_catch");
116116
Expression *efunc = VarExp::create(Loc(), fdend);
117117
Expression *ecall = CallExp::create(Loc(), efunc);
118118
ecall->type = Type::tvoid;

runtime/druntime/src/etc/linux/memoryerror.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ version (linux)
4040

4141
version (MemoryErrorSupported)
4242
version = AnySupported;
43-
else version (MemoryErrorSupported)
43+
else version (MemoryAssertSupported)
4444
version = AnySupported;
4545

4646
version (AnySupported):

runtime/phobos

0 commit comments

Comments
 (0)