diff options
author | Ian Lance Taylor <iant@golang.org> | 2023-10-19 17:20:40 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2023-10-23 14:05:15 -0700 |
commit | ac50e9b72bf9bb6d5b28096bb164fb050db6e290 (patch) | |
tree | bce331b661c84c983e82d655350e20d91165abd6 /gcc/go/gofrontend/expressions.h | |
parent | 2621bd1bac614b63e52d0deb4ab2ff287a9fafa8 (diff) | |
download | gcc-ac50e9b72bf9bb6d5b28096bb164fb050db6e290.zip gcc-ac50e9b72bf9bb6d5b28096bb164fb050db6e290.tar.gz gcc-ac50e9b72bf9bb6d5b28096bb164fb050db6e290.tar.bz2 |
compiler: add Expression::is_untyped method
This method is not currently used by anything, but it will be used
by later CLs in this series.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536639
Diffstat (limited to 'gcc/go/gofrontend/expressions.h')
-rw-r--r-- | gcc/go/gofrontend/expressions.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index 2abc9cb..49140d1 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -566,6 +566,15 @@ class Expression is_constant() const { return this->do_is_constant(); } + // Return whether this expression is untyped. This isn't quite the + // same as is_constant with an abstract type, as 1<<val is untyped + // even if val is a variable. If this returns true, it sets *PTYPE + // to an abstract type, which is the type the expression will have + // if there is no context. + bool + is_untyped(Type** ptype) const + { return this->do_is_untyped(ptype); } + // Return whether this is the zero value of its type. bool is_zero_value() const @@ -1169,6 +1178,11 @@ class Expression do_is_constant() const { return false; } + // Return whether this expression is untyped. + virtual bool + do_is_untyped(Type**) const + { return false; } + // Return whether this is the zero value of its type. virtual bool do_is_zero_value() const @@ -1274,6 +1288,12 @@ class Expression void report_error(const char*); + // A convenience function for handling a type in do_is_untyped. If + // TYPE is not abstract, return false. Otherwise set *PTYPE to TYPE + // and return true. + static bool + is_untyped_type(Type* type, Type** ptype); + // Write a name to export data. static void export_name(Export_function_body* efb, const Named_object*); @@ -1502,6 +1522,9 @@ class Const_expression : public Expression { return true; } bool + do_is_untyped(Type**) const; + + bool do_is_zero_value() const; bool @@ -1831,6 +1854,9 @@ class String_expression : public Expression { return true; } bool + do_is_untyped(Type**) const; + + bool do_is_zero_value() const { return this->val_ == ""; } @@ -2137,6 +2163,9 @@ class Unary_expression : public Expression do_is_constant() const; bool + do_is_untyped(Type**) const; + + bool do_is_static_initializer() const; bool @@ -2294,6 +2323,9 @@ class Binary_expression : public Expression { return this->left_->is_constant() && this->right_->is_constant(); } bool + do_is_untyped(Type**) const; + + bool do_is_static_initializer() const; bool @@ -2416,6 +2448,9 @@ class String_concat_expression : public Expression do_is_constant() const; bool + do_is_untyped(Type**) const; + + bool do_is_zero_value() const; bool @@ -2768,6 +2803,9 @@ class Builtin_call_expression : public Call_expression do_is_constant() const; bool + do_is_untyped(Type**) const; + + bool do_numeric_constant_value(Numeric_constant*) const; bool |