aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/expressions.h
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2020-01-09 15:58:42 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2020-01-09 15:58:42 +0000
commit0581e6ba3cfeb646553574aaa0efb1a822550a1f (patch)
treefa419773d258339a511cb550a8739b57ca49d154 /gcc/go/gofrontend/expressions.h
parentd6491d15676b0255eaaa4f5394fbb8ec7e3c6a5f (diff)
downloadgcc-0581e6ba3cfeb646553574aaa0efb1a822550a1f.zip
gcc-0581e6ba3cfeb646553574aaa0efb1a822550a1f.tar.gz
gcc-0581e6ba3cfeb646553574aaa0efb1a822550a1f.tar.bz2
compiler: don't add composite literal keys to package bindings
Adding composite literal keys to package bindings gets confusing when it is combined with dot imports. The test case showing the resulting compilation failure is https://golang.org/cl/213899. Fix this by adding a new expression type to hold composite literal keys. We shouldn't see it during lowering if it is a struct field name, because Composite_literal_expression::do_traverse skips struct field names. Or, it should, but that didn't quite work with pointer types so it had to be tweaked. This lets us remove the code that recorded whether an Unknown_expression is a composite literal key. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/214017 From-SVN: r280056
Diffstat (limited to 'gcc/go/gofrontend/expressions.h')
-rw-r--r--gcc/go/gofrontend/expressions.h22
1 files changed, 6 insertions, 16 deletions
diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h
index a0370e1..a4f892a 100644
--- a/gcc/go/gofrontend/expressions.h
+++ b/gcc/go/gofrontend/expressions.h
@@ -127,6 +127,7 @@ class Expression
EXPRESSION_SLICE_CONSTRUCTION,
EXPRESSION_MAP_CONSTRUCTION,
EXPRESSION_COMPOSITE_LITERAL,
+ EXPRESSION_COMPOSITE_LITERAL_KEY,
EXPRESSION_HEAP,
EXPRESSION_RECEIVE,
EXPRESSION_TYPE_DESCRIPTOR,
@@ -384,6 +385,10 @@ class Expression
make_composite_literal(Type*, int depth, bool has_keys, Expression_list*,
bool all_are_names, Location);
+ // Make a composite literal key.
+ static Expression*
+ make_composite_literal_key(const std::string& name, Location);
+
// Make a struct composite literal.
static Expression*
make_struct_composite_literal(Type*, Expression_list*, Location);
@@ -2881,8 +2886,7 @@ class Unknown_expression : public Parser_expression
public:
Unknown_expression(Named_object* named_object, Location location)
: Parser_expression(EXPRESSION_UNKNOWN_REFERENCE, location),
- named_object_(named_object), no_error_message_(false),
- is_composite_literal_key_(false)
+ named_object_(named_object), no_error_message_(false)
{ }
// The associated named object.
@@ -2901,18 +2905,6 @@ class Unknown_expression : public Parser_expression
set_no_error_message()
{ this->no_error_message_ = true; }
- // Note that this expression is being used as the key in a composite
- // literal, so it may be OK if it is not resolved.
- void
- set_is_composite_literal_key()
- { this->is_composite_literal_key_ = true; }
-
- // Note that this expression should no longer be treated as a
- // composite literal key.
- void
- clear_is_composite_literal_key()
- { this->is_composite_literal_key_ = false; }
-
protected:
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
@@ -2930,8 +2922,6 @@ class Unknown_expression : public Parser_expression
// True if we should not give errors if this is undefined. This is
// used if there was a parse failure.
bool no_error_message_;
- // True if this is the key in a composite literal.
- bool is_composite_literal_key_;
};
// An index expression. This is lowered to an array index, a string