[Issue 1678] ref with varargs generates invalid code
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 26 13:05:55 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1678
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #7 from Don <clugdbug at yahoo.com.au> 2010-07-26 13:03:13 PDT ---
There's probably a simpler way to patch this. What I've done is find the first
non-ref parameter, and set __argptr off it.
Index: func.c
===================================================================
--- func.c (revision 588)
+++ func.c (working copy)
@@ -1367,18 +1367,32 @@
#else
Type *t = argptr->type;
VarDeclaration *p;
- unsigned offset;
-
+ unsigned offset = 0;
Expression *e1 = new VarExp(0, argptr);
+ // Find the last non-ref parameter
if (parameters && parameters->dim)
- p = (VarDeclaration *)parameters->data[parameters->dim -
1];
+ {
+ int lastNonref = parameters->dim -1;
+ p = (VarDeclaration *)parameters->data[lastNonref];
+ while (p->storage_class & (STCout | STCref))
+ {
+ --lastNonref;
+ offset += PTRSIZE;
+ if (lastNonref < 0)
+ {
+ p = v_arguments;
+ break;
+ }
+ p = (VarDeclaration *)parameters->data[lastNonref];
+ }
+ }
else
- p = v_arguments; // last parameter is
_arguments[]
+ p = v_arguments;
if (p->storage_class & STClazy)
// If the last parameter is lazy, it's the size of a
delegate
- offset = PTRSIZE * 2;
+ offset += PTRSIZE * 2;
else
- offset = p->type->size();
+ offset += p->type->size();
offset = (offset + 3) & ~3; // assume stack aligns on 4
Expression *e = new SymOffExp(0, p, offset);
e->type = Type::tvoidptr;
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list