aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2019-10-04 18:14:30 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2019-10-04 18:14:30 +0000
commit69b35f396ceb22e2e04b4228a6811291621808c1 (patch)
treee5b8c8a1488b30e41d0039391145aeb734ef6f6f /gcc
parent432bbcbb1e9d4a2b2bd946a0120c2be52c4ec01d (diff)
downloadgcc-69b35f396ceb22e2e04b4228a6811291621808c1.zip
gcc-69b35f396ceb22e2e04b4228a6811291621808c1.tar.gz
gcc-69b35f396ceb22e2e04b4228a6811291621808c1.tar.bz2
compiler: include selected constant types during export processing
The machinery that collects types referenced by expressions that are part of inlinable function bodies was missing the types of local named constants in certain cases. This patch updates the Collect_export_references::expression() hook to look for references to local named constants and include their types in the exported set. Fixes golang/go#34577. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/198017 From-SVN: r276594
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/export.cc12
-rw-r--r--gcc/go/gofrontend/expressions.cc13
-rw-r--r--gcc/go/gofrontend/expressions.h5
4 files changed, 31 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index bb50994..1508eb1 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-441f3f1f350b532707c48273d7f454cf1c4e959f
+ddfb845fad1f2e8b84383f262ed5ea5be7b3e35a
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/export.cc b/gcc/go/gofrontend/export.cc
index 32ab498..5aaa207 100644
--- a/gcc/go/gofrontend/export.cc
+++ b/gcc/go/gofrontend/export.cc
@@ -249,6 +249,14 @@ Collect_export_references::expression(Expression** pexpr)
return TRAVERSE_CONTINUE;
}
+ const Named_object* nco = expr->named_constant();
+ if (nco != 0 && nco->package() == NULL)
+ {
+ const Named_constant *nc = nco->const_value();
+ Type::traverse(nc->type(), this);
+ return TRAVERSE_CONTINUE;
+ }
+
return TRAVERSE_CONTINUE;
}
@@ -322,6 +330,10 @@ Collect_export_references::type(Type* type)
if (type->is_void_type())
return TRAVERSE_SKIP_COMPONENTS;
+ // Skip the nil type, turns up in function bodies.
+ if (type->is_nil_type())
+ return TRAVERSE_SKIP_COMPONENTS;
+
// Skip abstract types. We should never see these in real code,
// only in things like const declarations.
if (type->is_abstract())
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 9babc34..b614921 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -3234,6 +3234,10 @@ class Const_expression : public Expression
named_object()
{ return this->constant_; }
+ const Named_object*
+ named_object() const
+ { return this->constant_; }
+
// Check that the initializer does not refer to the constant itself.
void
check_for_init_loop();
@@ -16782,6 +16786,15 @@ Expression::is_local_variable() const
|| (no->is_variable() && !no->var_value()->is_global()));
}
+const Named_object*
+Expression::named_constant() const
+{
+ if (this->classification() != EXPRESSION_CONST_REFERENCE)
+ return NULL;
+ const Const_expression* ce = static_cast<const Const_expression*>(this);
+ return ce->named_object();
+}
+
// Class Type_guard_expression.
// Traversal.
diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h
index 2e3d1e0..a0370e1 100644
--- a/gcc/go/gofrontend/expressions.h
+++ b/gcc/go/gofrontend/expressions.h
@@ -587,6 +587,11 @@ class Expression
boolean_constant_value(bool* val) const
{ return this->do_boolean_constant_value(val); }
+ // If this is a const reference expression, return the named
+ // object to which the expression refers, otherwise return NULL.
+ const Named_object*
+ named_constant() const;
+
// This is called if the value of this expression is being
// discarded. This issues warnings about computed values being
// unused. This returns true if all is well, false if it issued an