diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-04-13 01:03:55 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-04-13 01:03:55 +0000 |
commit | fdc59f56c1038ce194b72aebe29ac9cd4150205c (patch) | |
tree | 8a84c446c3b83550be24819a0adf3496f802642f /gcc/go/gofrontend/expressions.h | |
parent | b15937488e5738ae2d4653dcc10acbd95eb649b5 (diff) | |
download | gcc-fdc59f56c1038ce194b72aebe29ac9cd4150205c.zip gcc-fdc59f56c1038ce194b72aebe29ac9cd4150205c.tar.gz gcc-fdc59f56c1038ce194b72aebe29ac9cd4150205c.tar.bz2 |
compiler: improve type handling for string concat ops on constants
Resolve a small problem with concatenation of string constants: in a
string concat X + Y where X has named type and Y has abstract string
type, insure that the result has X's type, and disable folding if the
both sides have a concrete type that does not match.
Fixes golang/go#31412.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/171797
From-SVN: r270336
Diffstat (limited to 'gcc/go/gofrontend/expressions.h')
-rw-r--r-- | gcc/go/gofrontend/expressions.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index c521d9b..43aaccf 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -230,6 +230,10 @@ class Expression static Expression* make_string(const std::string&, Location); + // Make a constant string expression with a specific string subtype. + static Expression* + make_string_typed(const std::string&, Type*, Location); + // Make an expression that evaluates to some characteristic of an string. // For simplicity, the enum values must match the field indexes in the // underlying struct. @@ -1570,9 +1574,9 @@ class Set_and_use_temporary_expression : public Expression class String_expression : public Expression { public: - String_expression(const std::string& val, Location location) + String_expression(const std::string& val, Type* type, Location location) : Expression(EXPRESSION_STRING, location), - val_(val), type_(NULL) + val_(val), type_(type) { } const std::string& |