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.
From-SVN: r216489
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.
From-SVN: r216487
PR c/63307
gcc/c-family/
* cilk.c: Include vec.h.
(struct cilk_decls): New structure.
(wrapper_parm_cb): Split this function to...
(fill_decls_vec): ...this...
(create_parm_list): ...and this.
(compare_decls): New function.
(for_local_cb): Remove.
(wrapper_local_cb): Ditto.
(build_wrapper_type): For now first traverse and fill vector of
declarations then sort it and then deal with sorted vector.
(cilk_outline): Ditto.
(declare_one_free_variable): Ditto.
From-SVN: r216483
2014-10-20 Robert Dewar <dewar@adacore.com>
* sem_ch3.adb, prj-proc.adb, prj-proc.ads, prj-conf.adb: Minor
reformatting.
2014-10-20 Robert Dewar <dewar@adacore.com>
* par-prag.adb (Add_List_Pragma_Entry): New procedure.
* par.adb (P_Pragma): Document requirement to handle multiple calls.
2014-10-20 Robert Dewar <dewar@adacore.com>
* sem_prag.adb (Analyze_Pragma, case No_Elaboration_Code_All):
Fix error of bad inheritance of this pragma from with'ed unit.
2014-10-20 Ed Schonberg <schonberg@adacore.com>
* sem_ch13.adb (Inherit_Aspects_At_Freeze_Point): For a subtype,
inherit convention from parent type, because the subtype may
have been declared on a partial view, prior to the pragma on
the parent.
2014-10-20 Olivier Hainque <hainque@adacore.com>
Tristan Gingold <gingold@adacore.com>
* gcc-interface/Makefile.in: Handle arm-darwin and VxWorks 7.
Misc clean ups.
2014-10-20 Nicolas Roche <roche@adacore.com>
* gcc-interface/Make-lang.in: ensure that automatically generated
dependency are referencing generated gnatvsn rather than original
one.
From-SVN: r216482
2014-10-20 Vincent Celier <celier@adacore.com>
* prj-attr.adb: New project level attribute Runtime.
* prj-conf.adb (Get_Project_Runtimes): New procedure to get
the attributes Runtime declared in the main project, to use
in auto-configuration.
(Get_Or_Create_Configuration_File): Call Get_Project_Runtimes.
* prj-proc.adb (Runtime_Defaults): New table to store
the default values of attributes Runtime (<language>).
(Set_Default_Runtime_For): New procedure to store the default
value of a Runtime (<language>) in table Runtime_Defaults.
(Expression): Use the value stored in table Runtime_Defaults as
the default for Runtime (<language>).
* prj-proc.ads (Set_Default_Runtime_For): New procedure.
* prj.ads (Attribute_Default_Value): New enumerated value
Runtime_Value.
2014-10-20 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Analyze_Object_Declaration): If the type is
an unconstrained unchecked_union type, rewrite declaration
as a renaming to prevent attempt to retrieve non- existent
discriminants from expression.
2014-10-20 Ed Schonberg <schonberg@adacore.com>
* gnat_ugn.texi: Minor reformatting.
From-SVN: r216479
2014-10-20 Tristan Gingold <gingold@adacore.com>
* init.c (__gnat_is_stack_guard): Don't use mach_vm_region_recurse on
arm-darwin.
* raise-gcc.c: Add ATTRIBUTE_UNUSED to remove warnings for
unused arguments.
2014-10-20 Hristian Kirtchev <kirtchev@adacore.com>
* sem_attr.adb (Analyze_Attribute): Replace
variables CS and PS with Proc_Id and Subp_Id to better illustrate
their purpose. Account for the case where _Postconditions
has not been generated yet and the context is aspect/pragma
Refined_Post. In that scenario the expected prefix of attribute
'Result is the current scope.
2014-10-20 Robert Dewar <dewar@adacore.com>
* par-ch4.adb (P_Expression): Handle extraneous comma/semicolon
in middle of expression with logical operators.
2014-10-20 Robert Dewar <dewar@adacore.com>
* par-ch13.adb (Possible_Misspelled_Aspect): New function.
2014-10-20 Steve Baird <baird@adacore.com>
* pprint.adb: Improve Expression_Image function.
From-SVN: r216477
2014-10-20 Robert Dewar <dewar@adacore.com>
* sem_ch3.adb, prj-proc.adb, sem_ch4.adb, prj-env.adb, lib.ads,
sem_ch13.adb: Minor reformatting.
2014-10-20 Javier Miranda <miranda@adacore.com>
* exp_ch3.adb (Expand_N_Object_Declaration): Expand the
declaration of a class-wide limited object containing an
initializing expression into a renaming declaration. Required to
avoid passing such declaration to the backend and also to avoid
generating an extra copy.
From-SVN: r216475
2014-10-20 Eric Botcazou <ebotcazou@adacore.com>
* inline.adb (List_Inlining_Info): Minor tweaks.
(Add_Inlined_Body): Inline the enclosing package
if it is not internally generated, even if it doesn't come
from source.
2014-10-20 Ed Schonberg <schonberg@adacore.com>
* sem_ch4.adb (Process_Function_Call): If the first actual
denotes a discrete type, the mode must be interpreted as a slice
of an array returned by a parameterless call.
2014-10-20 Vasiliy Fofanov <fofanov@adacore.com>
* prj-env.ads, prj-env.adb (Get_Runtime_Path): No longer inhibit
searching for runtime referenced by a simple name on a project path.
2014-10-20 Olivier Hainque <hainque@adacore.com>
* vxworks-x86-link.spec: New file.
* system-vxworks-x86.ads: Add pragma Linker_Options to link with
vxworks-x86-link.spec.
2014-10-20 Vincent Celier <celier@adacore.com>
* opt.ads (Origin_Of_Target): New type.
(Target_Origin): New variable.
* prj-conf.adb (Parse_Project_And_Apply_Config): Record
Target_Value and Target_Origin. If target was not specified
on the command line with --target=, check if attribute Target
is declared in the main project. If it is and it is not the
native target, parse again the projects so that 'Target get
the new value. Fail if the target has changed again. Invoke
Process_Project_And_Apply_Config with Do_Phase_1 set to False
is Process_Project_Tree_Phase_1 has already been invoked.
* prj-conf.ads (Process_Project_And_Apply_Config): New Boolean
parameter Do_Phase_1, defaulted to True.
* prj-proc.adb (Expression): Check the special values and
defaults for attribute Target.
2014-10-20 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Handle_Late_Controlled_Primitive): Do not analyze
the subprogram spec of the body in full, because it will be
reanalyzed when the declaration itself is analyzed; otherwise. a
formal may end up duplicated in the list of formals leading to
spurious conformance errors with an existing declaration.
From-SVN: r216473
2014-10-20 Arnaud Charlet <charlet@adacore.com>
* set_targ.adb (Write_Target_Dependent_Values, Write_Line):
Fix calling C APIs with no trailing NUL char by calling better
wrappers instead.
2014-10-20 Tristan Gingold <gingold@adacore.com>
* gnat_ugn.texi: Document that gdb users must be in group
_developer on mac os.
2014-10-20 Arnaud Charlet <charlet@adacore.com>
* a-tgdico.ads: Fix typo.
2014-10-20 Ed Schonberg <schonberg@adacore.com>
* exp_aggr.adb (Convert_To_Assignments): Do not create a
transient scope for a component whose type requires it, if the
context is an initialization procedure, because the target of
the assignment must be visible outside of the block.
2014-10-20 Tristan Gingold <gingold@adacore.com>
* tracebak.c: Define PC_ADJUST for arm-darwin.
* env.c: Remove darwin specific code.
* raise-gcc.c (__gnat_Unwind_ForcedUnwind): Error on arm-darwin.
2014-10-20 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Analyze_Full_Type_Declaration): If previous view
is incomplete rather than private, and full type declaration
has aspects, analyze aspects on the full view rather than
the incomplete view, to prevent freezing anomalies with the
class-wide type.
From-SVN: r216470
2014-10-20 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/slsr-19.c: Make robust against operand order changes.
* gcc.dg/tree-ssa/reassoc-20.c: Likewise.
From-SVN: r216465
2014-10-20 Richard Biener <rguenther@suse.de>
* tree-vect-slp.c (vect_get_and_check_slp_defs): Try swapping
operands to get a def operand kind match. Signal mismatches
to the parent so we can try swapping its operands.
(vect_build_slp_tree): Try swapping operands if they have
a mismatched operand kind.
From-SVN: r216463
* varasm.c (const_alias_set): Remove.
(init_varasm_once): Remove initialization of const_alias_set.
(build_constant_desc): Do not set alias set to const_alias_set.
From-SVN: r216454
gcc/
* configure: Regenerate.
* configure.ac: Move the test for section attribute specifier "e" in GAS
out to all i[34567]86-*-* | x86_64-*-* targets and add --fatal-warnings.
* langhooks.c (lhd_begin_section): Set SECTION_EXCLUDE flag.
* varasm.c (default_elf_asm_named_section): Guard SECTION_EXCLUDE with
ifdef HAVE_GAS_SECTION_EXCLUDE.
From-SVN: r216442
PR c/63567
* c-typeck.c (output_init_element): Allow initializing objects with
static storage duration with compound literals even in C99 and add
pedwarn for it.
* gcc.dg/pr63567-3.c: New test.
* gcc.dg/pr63567-4.c: New test.
From-SVN: r216440
2014-10-19 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
David Edelsohn <dje.gcc@gmail.com>
* config/rs6000/rs6000.c (rs6000_atomic_assign_expand_fenv): New
function.
(TARGET_ATOMIC_ASSIGN_EXPAND_FENV): New define.
* gcc.dg/atomic/c11-atomic-exec-5.c
(test_main_long_double_add_overflow): Define and run only for
LDBL_MANT_DIG != 106.
(test_main_complex_long_double_add_overflow): Likewise.
(test_main_long_double_sub_overflow): Likewise.
(test_main_complex_long_double_sub_overflow): Likewise.
Co-Authored-By: David Edelsohn <dje.gcc@gmail.com>
From-SVN: r216437
2014-10-18 Manuel López-Ibáñez <manu@gcc.gnu.org>
* doc/invoke.texi (Options to Request or Suppress Warnings):
Explain options precedence.
(Wtrampolines): Do not indent paragraph.
From-SVN: r216429
2014-10-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/63553
* resolve.c (resolve_ordinary_assign): Add data component to
rvalue expression for class to type assignment.
2014-10-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/63553
* gfortran.dg/class_to_type_3.f03 : New test
From-SVN: r216427
PR c/63567
* c-typeck.c (digest_init): Allow initializing objects with static
storage duration with compound literals even in C99 and add pedwarn
for it.
* gcc.dg/pr61096-1.c: Change dg-error into dg-warning.
* gcc.dg/pr63567-1.c: New test.
* gcc.dg/pr63567-2.c: New test.
From-SVN: r216416
* ipa-inline-transform.c (master_clone_with_noninline_clones_p): New.
(clone_inlined_nodes): Do not overwrite the clone if above predicate
returns true.
From-SVN: r216415
2014-10-17 Andrew MacLeod <amacleod@redhat.com>
* gcc-plugin.h: Add tm.h and flattened includes from function.h.
* testsuite/g++.dg/plugin/pragma_plugin.c: Revert flattening, only
include function.h.
From-SVN: r216402