diff options
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/ChangeLog | 33 | ||||
-rw-r--r-- | gcc/go/Make-lang.in | 2 | ||||
-rw-r--r-- | gcc/go/config-lang.in | 2 | ||||
-rw-r--r-- | gcc/go/gccgo.texi | 2 | ||||
-rw-r--r-- | gcc/go/go-backend.c | 2 | ||||
-rw-r--r-- | gcc/go/go-c.h | 2 | ||||
-rw-r--r-- | gcc/go/go-gcc.cc | 79 | ||||
-rw-r--r-- | gcc/go/go-lang.c | 2 | ||||
-rw-r--r-- | gcc/go/go-system.h | 2 | ||||
-rw-r--r-- | gcc/go/gospec.c | 2 | ||||
-rw-r--r-- | gcc/go/lang-specs.h | 2 | ||||
-rw-r--r-- | gcc/go/lang.opt | 2 |
12 files changed, 104 insertions, 28 deletions
diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index 1a120950a13..d985328b181 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,34 @@ +2016-01-04 Jakub Jelinek <jakub@redhat.com> + + Update copyright years. + + * gccgo.texi: Bump @copyrights-go year. + +2015-12-21 Ian Lance Taylor <iant@google.com> + + * go-gcc.cc (class Bvariable): Remove Gcc_tree parent class. Add + t_ and orig_type_ fields. Add new two parameter constructor. Add + get_tree and get_decl methods. + (Gcc_backend::var_expression): Pass location to var get_tree. + (Gcc_backend::global_variable): Don't add VIEW_CONVERT_EXPR. Use + two parameter constructor for Bvariable. + (Gcc_backend::global_variable_set_init): Don't remove + VIEW_CONVERT_EXPR. Use var get_decl, not get_tree. + (Gcc_backend::write_global_definitions): Likewise. + (Gcc_backend::init_statement): Call var get_decl, not get_tree. + (Gcc_backend::block): Likewise. + (Gcc_backend::implicit_variable_set_init): Likewise. + (Gcc_backend::immutable_struct_set_init): Likewise. + (Gcc_backend::function_set_parameters): Likewise. + +2015-12-21 Ian Lance Taylor <iant@google.com> + + * go-gcc.cc (Gcc_backend::global_variable): If type is zero-sized, + add a VIEW_CONVERT_EXPR to the tree. + (Gcc_backend::global_variable_set_init): Remove any + VIEW_CONVERT_EXPR. + (Gcc_backend::write_global_definitions): Likewise. + 2015-11-30 Ian Lance Taylor <iant@google.com> PR go/68477 @@ -1135,7 +1166,7 @@ Go frontend added to gcc repository. -Copyright (C) 2010-2015 Free Software Foundation, Inc. +Copyright (C) 2010-2016 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/gcc/go/Make-lang.in b/gcc/go/Make-lang.in index 7db756f2e58..3240fe84497 100644 --- a/gcc/go/Make-lang.in +++ b/gcc/go/Make-lang.in @@ -1,6 +1,6 @@ # Make-lang.in -- Top level -*- makefile -*- fragment for gcc Go frontend. -# Copyright (C) 2009-2015 Free Software Foundation, Inc. +# Copyright (C) 2009-2016 Free Software Foundation, Inc. # This file is part of GCC. diff --git a/gcc/go/config-lang.in b/gcc/go/config-lang.in index 5b0ada4b7fa..8e27ade2220 100644 --- a/gcc/go/config-lang.in +++ b/gcc/go/config-lang.in @@ -1,6 +1,6 @@ # config-lang.in -- Top level configure fragment for gcc Go frontend. -# Copyright (C) 2009-2015 Free Software Foundation, Inc. +# Copyright (C) 2009-2016 Free Software Foundation, Inc. # This file is part of GCC. diff --git a/gcc/go/gccgo.texi b/gcc/go/gccgo.texi index 6e4c70874f9..0c58a1e3d1b 100644 --- a/gcc/go/gccgo.texi +++ b/gcc/go/gccgo.texi @@ -12,7 +12,7 @@ @include gcc-common.texi @c Copyright years for this manual. -@set copyrights-go 2010-2015 +@set copyrights-go 2010-2016 @copying @c man begin COPYRIGHT diff --git a/gcc/go/go-backend.c b/gcc/go/go-backend.c index 4873deab57a..1c62495c38d 100644 --- a/gcc/go/go-backend.c +++ b/gcc/go/go-backend.c @@ -1,5 +1,5 @@ /* go-backend.c -- Go frontend interface to gcc backend. - Copyright (C) 2010-2015 Free Software Foundation, Inc. + Copyright (C) 2010-2016 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/go/go-c.h b/gcc/go/go-c.h index ea3aa382936..98b2850be8c 100644 --- a/gcc/go/go-c.h +++ b/gcc/go/go-c.h @@ -1,5 +1,5 @@ /* go-c.h -- Header file for go frontend gcc C interface. - Copyright (C) 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2009-2016 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index cfb1995faf2..2793bb6090d 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -1,5 +1,5 @@ // go-gcc.cc -- Go frontend to gcc IR. -// Copyright (C) 2011-2015 Free Software Foundation, Inc. +// Copyright (C) 2011-2016 Free Software Foundation, Inc. // Contributed by Ian Lance Taylor, Google. // This file is part of GCC. @@ -109,22 +109,65 @@ class Bblock : public Gcc_tree { } }; -class Bvariable : public Gcc_tree +class Blabel : public Gcc_tree { public: - Bvariable(tree t) + Blabel(tree t) : Gcc_tree(t) { } }; -class Blabel : public Gcc_tree +// Bvariable is a bit more complicated, because of zero-sized types. +// The GNU linker does not permit dynamic variables with zero size. +// When we see such a variable, we generate a version of the type with +// non-zero size. However, when referring to the global variable, we +// want an expression of zero size; otherwise, if, say, the global +// variable is passed to a function, we will be passing a +// non-zero-sized value to a zero-sized value, which can lead to a +// miscompilation. + +class Bvariable { public: - Blabel(tree t) - : Gcc_tree(t) + Bvariable(tree t) + : t_(t), orig_type_(NULL) + { } + + Bvariable(tree t, tree orig_type) + : t_(t), orig_type_(orig_type) { } + + // Get the tree for use as an expression. + tree + get_tree(Location) const; + + // Get the actual decl; + tree + get_decl() const + { return this->t_; } + + private: + tree t_; + tree orig_type_; }; +// Get the tree of a variable for use as an expression. If this is a +// zero-sized global, create an expression that refers to the decl but +// has zero size. +tree +Bvariable::get_tree(Location location) const +{ + if (this->orig_type_ == NULL + || this->t_ == error_mark_node + || TREE_TYPE(this->t_) == this->orig_type_) + return this->t_; + // Return *(orig_type*)&decl. */ + tree t = build_fold_addr_expr_loc(location.gcc_location(), this->t_); + t = fold_build1_loc(location.gcc_location(), NOP_EXPR, + build_pointer_type(this->orig_type_), t); + return build_fold_indirect_ref_loc(location.gcc_location(), t); +} + // This file implements the interface between the Go frontend proper // and the gcc IR. This implements specific instantiations of // abstract classes defined by the Go frontend proper. The Go @@ -1158,9 +1201,9 @@ Gcc_backend::zero_expression(Btype* btype) // An expression that references a variable. Bexpression* -Gcc_backend::var_expression(Bvariable* var, Location) +Gcc_backend::var_expression(Bvariable* var, Location location) { - tree ret = var->get_tree(); + tree ret = var->get_tree(location); if (ret == error_mark_node) return this->error_expression(); return this->make_expression(ret); @@ -1894,7 +1937,7 @@ Gcc_backend::expression_statement(Bexpression* expr) Bstatement* Gcc_backend::init_statement(Bvariable* var, Bexpression* init) { - tree var_tree = var->get_tree(); + tree var_tree = var->get_decl(); tree init_tree = init->get_tree(); if (var_tree == error_mark_node || init_tree == error_mark_node) return this->error_statement(); @@ -2264,7 +2307,7 @@ Gcc_backend::block(Bfunction* function, Bblock* enclosing, pv != vars.end(); ++pv) { - *pp = (*pv)->get_tree(); + *pp = (*pv)->get_decl(); if (*pp != error_mark_node) pp = &DECL_CHAIN(*pp); } @@ -2390,6 +2433,7 @@ Gcc_backend::global_variable(const std::string& package_name, return this->error_variable(); // The GNU linker does not like dynamic variables with zero size. + tree orig_type_tree = type_tree; if ((is_external || !is_hidden) && int_size_in_bytes(type_tree) == 0) type_tree = this->non_zero_size_type(type_tree); @@ -2419,7 +2463,7 @@ Gcc_backend::global_variable(const std::string& package_name, go_preserve_from_gc(decl); - return new Bvariable(decl); + return new Bvariable(decl, orig_type_tree); } // Set the initial value of a global variable. @@ -2431,7 +2475,7 @@ Gcc_backend::global_variable_set_init(Bvariable* var, Bexpression* expr) if (expr_tree == error_mark_node) return; gcc_assert(TREE_CONSTANT(expr_tree)); - tree var_decl = var->get_tree(); + tree var_decl = var->get_decl(); if (var_decl == error_mark_node) return; DECL_INITIAL(var_decl) = expr_tree; @@ -2659,7 +2703,7 @@ Gcc_backend::implicit_variable_set_init(Bvariable* var, const std::string&, Btype*, bool, bool, bool is_common, Bexpression* init) { - tree decl = var->get_tree(); + tree decl = var->get_decl(); tree init_tree; if (init == NULL) init_tree = NULL_TREE; @@ -2753,7 +2797,7 @@ Gcc_backend::immutable_struct_set_init(Bvariable* var, const std::string&, bool, bool is_common, Btype*, Location, Bexpression* initializer) { - tree decl = var->get_tree(); + tree decl = var->get_decl(); tree init_tree = initializer->get_tree(); if (decl == error_mark_node || init_tree == error_mark_node) return; @@ -2972,7 +3016,7 @@ Gcc_backend::function_set_parameters(Bfunction* function, pv != param_vars.end(); ++pv) { - *pp = (*pv)->get_tree(); + *pp = (*pv)->get_decl(); gcc_assert(*pp != error_mark_node); pp = &DECL_CHAIN(*pp); } @@ -3028,9 +3072,10 @@ Gcc_backend::write_global_definitions( p != variable_decls.end(); ++p) { - if ((*p)->get_tree() != error_mark_node) + tree v = (*p)->get_decl(); + if (v != error_mark_node) { - defs[i] = (*p)->get_tree(); + defs[i] = v; go_preserve_from_gc(defs[i]); ++i; } diff --git a/gcc/go/go-lang.c b/gcc/go/go-lang.c index 37205e42ee8..16065241008 100644 --- a/gcc/go/go-lang.c +++ b/gcc/go/go-lang.c @@ -1,5 +1,5 @@ /* go-lang.c -- Go frontend gcc interface. - Copyright (C) 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2009-2016 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/go/go-system.h b/gcc/go/go-system.h index 9df1341e8ba..cb7e74500cf 100644 --- a/gcc/go/go-system.h +++ b/gcc/go/go-system.h @@ -1,5 +1,5 @@ // go-system.h -- Go frontend inclusion of gcc header files -*- C++ -*- -// Copyright (C) 2009-2015 Free Software Foundation, Inc. +// Copyright (C) 2009-2016 Free Software Foundation, Inc. // This file is part of GCC. diff --git a/gcc/go/gospec.c b/gcc/go/gospec.c index 98df65d7021..13c1b9c021e 100644 --- a/gcc/go/gospec.c +++ b/gcc/go/gospec.c @@ -1,5 +1,5 @@ /* gospec.c -- Specific flags and argument handling of the gcc Go front end. - Copyright (C) 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2009-2016 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/go/lang-specs.h b/gcc/go/lang-specs.h index 66cce3f85af..5fd8e9e36b3 100644 --- a/gcc/go/lang-specs.h +++ b/gcc/go/lang-specs.h @@ -1,5 +1,5 @@ /* lang-specs.h -- gcc driver specs for Go frontend. - Copyright (C) 2009-2015 Free Software Foundation, Inc. + Copyright (C) 2009-2016 Free Software Foundation, Inc. This file is part of GCC. diff --git a/gcc/go/lang.opt b/gcc/go/lang.opt index 3b304eac7bc..7d44e44800d 100644 --- a/gcc/go/lang.opt +++ b/gcc/go/lang.opt @@ -1,6 +1,6 @@ ; lang.opt -- Options for the gcc Go front end. -; Copyright (C) 2009-2015 Free Software Foundation, Inc. +; Copyright (C) 2009-2016 Free Software Foundation, Inc. ; ; This file is part of GCC. ; |