Skip to content
This repository was archived by the owner on Jun 20, 2019. It is now read-only.

Commit 7de7a0f

Browse files
committed
Remove IN_GCC code for xopCmp/xopEquals in compiler and library
1 parent e50fa4c commit 7de7a0f

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

gcc/d/dfrontend/clone.c

-4
Original file line numberDiff line numberDiff line change
@@ -664,11 +664,7 @@ FuncDeclaration *buildXopCmp(StructDeclaration *sd, Scope *sc)
664664
fop->generated = true;
665665
Expression *e1 = new IdentifierExp(loc, Id::p);
666666
Expression *e2 = new IdentifierExp(loc, Id::q);
667-
#ifdef IN_GCC
668667
Expression *e = new CallExp(loc, new DotIdExp(loc, e1, Id::cmp), e2);
669-
#else
670-
Expression *e = new CallExp(loc, new DotIdExp(loc, e2, Id::cmp), e1);
671-
#endif
672668

673669
fop->fbody = new ReturnStatement(loc, e);
674670

libphobos/libdruntime/object.d

+17-18
Original file line numberDiff line numberDiff line change
@@ -1145,12 +1145,7 @@ class TypeInfo_Struct : TypeInfo
11451145
return false;
11461146
else if (xopEquals)
11471147
{
1148-
version(GNU)
1149-
{ // BUG: GDC and DMD use different calling conventions
1150-
return (*xopEquals)(p2, p1);
1151-
}
1152-
else
1153-
return (*xopEquals)(p1, p2);
1148+
return (*xopEquals)(p1, p2);
11541149
}
11551150
else if (p1 == p2)
11561151
return true;
@@ -1171,14 +1166,7 @@ class TypeInfo_Struct : TypeInfo
11711166
if (!p2)
11721167
return true;
11731168
else if (xopCmp)
1174-
{
1175-
version(GNU)
1176-
{ // BUG: GDC and DMD use different calling conventions
1177-
return (*xopCmp)(p1, p2);
1178-
}
1179-
else
1180-
return (*xopCmp)(p2, p1);
1181-
}
1169+
return (*xopCmp)(p1, p2);
11821170
else
11831171
// BUG: relies on the GC not moving objects
11841172
return memcmp(p1, p2, initializer().length);
@@ -1225,10 +1213,21 @@ class TypeInfo_Struct : TypeInfo
12251213

12261214
@safe pure nothrow
12271215
{
1228-
size_t function(in void*) xtoHash;
1229-
bool function(in void*, in void*) xopEquals;
1230-
int function(in void*, in void*) xopCmp;
1231-
string function(in void*) xtoString;
1216+
size_t function(in void*) xtoHash;
1217+
/* The xopEquals and xopCmp function pointers usually point to the struct's
1218+
* opEquals and opCmp methods. If the method doesn't take its single
1219+
* argument by reference, the front-end injects a static __xopEquals/
1220+
* __xopCmp function (taking 2 arguments, lhs `p` and rhs `q`).
1221+
*
1222+
* In the method case, lhs `p` is the `this` argument and must be passed
1223+
* as first argument before rhs `q`.
1224+
* Enforce this arguments order by marking the pointed-to functions as
1225+
* using the C calling convention, for which the arguments are never
1226+
* reversed (contrary to `extern (D)`).
1227+
*/
1228+
extern (C) bool function(in void*, in void*) xopEquals;
1229+
extern (C) int function(in void*, in void*) xopCmp;
1230+
string function(in void*) xtoString;
12321231

12331232
enum StructFlags : uint
12341233
{

0 commit comments

Comments
 (0)