public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Go patch committed: Traverse types of constant expressions
@ 2019-09-09 19:07 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2019-09-09 19:07 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 382 bytes --]

We forgot to ever traverse types of constant expressions in the Go
frontend.  This rarely makes a difference--evidently, since nobody
noticed--but it does matter when we inline constant expressions: we
need to ensure that the type is visible to the importing code.  This
patch fixes the omissions.  Bootstrapped and ran Go tests on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 4128 bytes --]

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 275473)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-8f2b844acda70330f7c50b360f8c983d2676ecbb
+28c9053b3d507bef7bd56cb01c6b22deea354cdd
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/expressions.cc
===================================================================
--- gcc/go/gofrontend/expressions.cc	(revision 275396)
+++ gcc/go/gofrontend/expressions.cc	(working copy)
@@ -1812,6 +1812,9 @@ class Boolean_expression : public Expres
   do_import(Import_expression*, Location);
 
  protected:
+  int
+  do_traverse(Traverse*);
+
   bool
   do_is_constant() const
   { return true; }
@@ -1864,6 +1867,17 @@ class Boolean_expression : public Expres
   Type* type_;
 };
 
+// Traverse a boolean expression.  We just need to traverse the type
+// if there is one.
+
+int
+Boolean_expression::do_traverse(Traverse* traverse)
+{
+  if (this->type_ != NULL)
+    return Type::traverse(this->type_, traverse);
+  return TRAVERSE_CONTINUE;
+}
+
 // Get the type.
 
 Type*
@@ -1916,6 +1930,17 @@ Expression::make_boolean(bool val, Locat
 
 // Class String_expression.
 
+// Traverse a string expression.  We just need to traverse the type
+// if there is one.
+
+int
+String_expression::do_traverse(Traverse* traverse)
+{
+  if (this->type_ != NULL)
+    return Type::traverse(this->type_, traverse);
+  return TRAVERSE_CONTINUE;
+}
+
 // Get the type.
 
 Type*
@@ -2290,6 +2315,9 @@ class Integer_expression : public Expres
   dump_integer(Ast_dump_context* ast_dump_context, const mpz_t val);
 
  protected:
+  int
+  do_traverse(Traverse*);
+
   bool
   do_is_constant() const
   { return true; }
@@ -2353,6 +2381,17 @@ class Integer_expression : public Expres
   bool is_character_constant_;
 };
 
+// Traverse an integer expression.  We just need to traverse the type
+// if there is one.
+
+int
+Integer_expression::do_traverse(Traverse* traverse)
+{
+  if (this->type_ != NULL)
+    return Type::traverse(this->type_, traverse);
+  return TRAVERSE_CONTINUE;
+}
+
 // Return a numeric constant for this expression.  We have to mark
 // this as a character when appropriate.
 
@@ -2714,6 +2753,9 @@ class Float_expression : public Expressi
   dump_float(Ast_dump_context* ast_dump_context, const mpfr_t val);
 
  protected:
+  int
+  do_traverse(Traverse*);
+
   bool
   do_is_constant() const
   { return true; }
@@ -2773,6 +2815,17 @@ class Float_expression : public Expressi
   Type* type_;
 };
 
+// Traverse a float expression.  We just need to traverse the type if
+// there is one.
+
+int
+Float_expression::do_traverse(Traverse* traverse)
+{
+  if (this->type_ != NULL)
+    return Type::traverse(this->type_, traverse);
+  return TRAVERSE_CONTINUE;
+}
+
 // Return the current type.  If we haven't set the type yet, we return
 // an abstract float type.
 
@@ -2932,6 +2985,9 @@ class Complex_expression : public Expres
   dump_complex(Ast_dump_context* ast_dump_context, const mpc_t val);
 
  protected:
+  int
+  do_traverse(Traverse*);
+
   bool
   do_is_constant() const
   { return true; }
@@ -2995,6 +3051,17 @@ class Complex_expression : public Expres
   Type* type_;
 };
 
+// Traverse a complex expression.  We just need to traverse the type
+// if there is one.
+
+int
+Complex_expression::do_traverse(Traverse* traverse)
+{
+  if (this->type_ != NULL)
+    return Type::traverse(this->type_, traverse);
+  return TRAVERSE_CONTINUE;
+}
+
 // Return the current type.  If we haven't set the type yet, we return
 // an abstract complex type.
 
Index: gcc/go/gofrontend/expressions.h
===================================================================
--- gcc/go/gofrontend/expressions.h	(revision 275396)
+++ gcc/go/gofrontend/expressions.h	(working copy)
@@ -1670,6 +1670,9 @@ class String_expression : public Express
   do_import(Import_expression*, Location);
 
  protected:
+  int
+  do_traverse(Traverse*);
+
   bool
   do_is_constant() const
   { return true; }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-09 19:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-09 19:07 Go patch committed: Traverse types of constant expressions Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).