2014-10-20  Eric Botcazou  <ebotcazou@adacore.com>

	* sem_ch3.adb (Build_Derived_Private_Type): When the parent
	is untagged and has discriminants, build the implicit full
	view even if the derived type is a completion, and make it
	the Underlying_Full_View of the type.
	(Copy_And_Build): Fix Is_Completion actual parameter in the calls to
	Build_Derived_Type.
	(Build_Derived_Record_Type): Likewise.

2014-10-20  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch13.adb: Add guard to convention setting.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@216487 138bc75d-0d04-0410-961f-82ee72b054a4
	PR c++/63601
	* lambda.c (current_nonlambda_function): New.
	* semantics.c (finish_this_expr): Use it.
	* cp-tree.h: Declare it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@216488 138bc75d-0d04-0410-961f-82ee72b054a4
reflect: allocate correct type in assignTo and cvtT2I

Backport https://codereview.appspot.com/155450044 from the
master Go library.  Original description:

I came across this while debugging a GC problem in gccgo.
There is code in assignTo and cvtT2I that handles assignment
to all interface values.  It allocates an empty interface even
if the real type is a non-empty interface.  The fields are
then set for a non-empty interface, but the memory is recorded
as holding an empty interface.  This means that the GC has
incorrect information.

This is extremely unlikely to fail, because the code in the GC
that handles empty interfaces looks like this:

obj = nil;
typ = eface->type;
if(typ != nil) {
        if(!(typ->kind&KindDirectIface) || !(typ->kind&KindNoPointers))
                obj = eface->data;

In the current runtime the condition is always true--if
KindDirectIface is set, then KindNoPointers is clear--and we
always want to set obj = eface->data.  So the question is what
happens when we incorrectly store a non-empty interface value
in memory marked as an empty interface.  In that case
eface->type will not be a *rtype as we expect, but will
instead be a pointer to an Itab.  We are going to use this
pointer to look at a *rtype kind field.  The *rtype struct
starts out like this:

type rtype struct {
        size          uintptr
        hash          uint32            // hash of type; avoids computation in hash tables
        _             uint8             // unused/padding
        align         uint8             // alignment of variable with this type
        fieldAlign    uint8             // alignment of struct field with this type
        kind          uint8             // enumeration for C

An Itab always has at least two pointers, so on a
little-endian 64-bit system the kind field will be the high
byte of the second pointer.  This will normally be zero, so
the test of typ->kind will succeed, which is what we want.

On a 32-bit system it might be possible to construct a failing
case by somehow getting the Itab for an interface with one
method to be immediately followed by a word that is all ones.
The effect would be that the test would sometimes fail and the
GC would not mark obj, leading to an invalid dangling
pointer.  I have not tried to construct this test.

I noticed this in gccgo, where this error is much more likely
to cause trouble for a rather random reason: gccgo uses a
different layout of rtype, and in gccgo the kind field happens
to be the low byte of a pointer, not the high byte.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@216489 138bc75d-0d04-0410-961f-82ee72b054a4