On 13 February 2013 15:20, Iain Buclaw <ibuc...@ubuntu.com> wrote: > On 13 February 2013 14:35, Johannes Pfau <nos...@example.com> wrote: > >> Am Wed, 13 Feb 2013 14:10:26 +0000 >> schrieb Iain Buclaw <ibuc...@ubuntu.com>: >> >> > On 13 February 2013 13:26, Johannes Pfau <nos...@example.com> wrote: >> > >> > > Am Tue, 12 Feb 2013 18:16:31 +0000 >> > > schrieb Iain Buclaw <ibuc...@ubuntu.com>: >> > > >> > > > TREE_ADDRESSABLE should be sufficient. I can't think any reason >> > > > off the top of my head why not. >> > > > >> > > >> > > maybe TREE_ADDRESSABLE is too strong: It generates errors in the >> > > backend if the frontend produces non-lvalues: >> > > --- >> > > auto b = Date(); >> > > a(b); >> > > --- >> > > >> > > works, but >> > > --- >> > > a(Date()); >> > > --- >> > > >> > > fails in gimplify.c. Do we really have to rewrite such cases so that >> > > non-PODs get a temporary variable? And how would this be done? It >> > > seems we would have to use the frontend for this, as maybeMakeTemp >> > > and makeTemp refuse to work for TREE_ADDRESSABLE types. >> > > >> > >> > Don't set it on the variable, set it on the type. >> > >> > TypeStruct::toCtype() >> > { >> > TYPE_ADDRESSABLE(ctype) = !isPOD(); >> > } >> >> That's actually what I did. But the backend wants to create a copy of >> the Date type which then fails as create_tmp_var fails for >> TREE_ADDRESSABLE types. >> >> Complete test case: >> https://gist.github.com/jpf91/4944999 >> >> ----- >> >> ../../objdir-4.7/x86_64-unknown-linux-gnu/libphobos/dm-test.reduced/datetime2.d:22: >> internal compiler error: in create_tmp_var, at gimplify.c:479 0x804509 >> ----- >> >> > > Ahh, that's because of this piece of codegen: > > SAVE_EXPR <*test.Date.this (&((void) (__ctmp971 = _D4test4Date6__initZ);, > __ctmp971), 0)> > > > Gimple doesn't like the dereference in SAVE_EXPR. This should work. > > tree > IRState::makeTemp (tree t) > { > tree type = TREE_TYPE (t); > if (TREE_CODE (type) != ARRAY_TYPE && !TREE_ADDRESSABLE (type)) > return save_expr (t); > > return stabilize_reference (t); > } > > > So the generated code is now: > > *SAVE_EXPR <test.Date.this (&((void) (__ctmp971 = _D4test4Date6__initZ);, > __ctmp971), 0)> > > After some more playing about, David's suggestion would be the quickest. ;-)
-- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';