diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-08-28 18:27:30 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2019-08-28 18:27:30 +0000 |
commit | fc4f90f0c8eca75fb90c736476360584f68d7ef9 (patch) | |
tree | ff64bd8a2576d7eb0b85638a14cc3a761cb72db1 /gcc/go/gofrontend/expressions.h | |
parent | 464969eb9b47eb2f24403c74c16769a58dbaa638 (diff) | |
download | gcc-fc4f90f0c8eca75fb90c736476360584f68d7ef9.zip gcc-fc4f90f0c8eca75fb90c736476360584f68d7ef9.tar.gz gcc-fc4f90f0c8eca75fb90c736476360584f68d7ef9.tar.bz2 |
compiler, runtime: provide index information on bounds check failure
This implements https://golang.org/cl/161477 in the gofrontend.
Updates golang/go#30116
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191881
From-SVN: r274998
Diffstat (limited to 'gcc/go/gofrontend/expressions.h')
-rw-r--r-- | gcc/go/gofrontend/expressions.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index 3b65e7a..4c743da 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -1059,10 +1059,11 @@ class Expression static Expression* import_expression(Import_expression*, Location); - // Return an expression which checks that VAL, of arbitrary integer type, - // is non-negative and is not more than the maximum integer value. - static Expression* - check_bounds(Expression* val, Location); + // Insert bounds checks for an index expression. + static void + check_bounds(Expression* val, Operator, Expression* bound, Runtime::Function, + Runtime::Function, Runtime::Function, Runtime::Function, + Statement_inserter*, Location); // Return an expression for constructing a direct interface type from a // pointer. @@ -2998,7 +2999,7 @@ class Array_index_expression : public Expression Expression* end, Expression* cap, Location location) : Expression(EXPRESSION_ARRAY_INDEX, location), array_(array), start_(start), end_(end), cap_(cap), type_(NULL), - is_lvalue_(false), needs_bounds_check_(true) + is_lvalue_(false), needs_bounds_check_(true), is_flattened_(false) { } // Return the array. @@ -3121,6 +3122,8 @@ class Array_index_expression : public Expression bool is_lvalue_; // Whether bounds check is needed. bool needs_bounds_check_; + // Whether this has already been flattened. + bool is_flattened_; }; // A string index. This is used for both indexing and slicing. @@ -3131,7 +3134,7 @@ class String_index_expression : public Expression String_index_expression(Expression* string, Expression* start, Expression* end, Location location) : Expression(EXPRESSION_STRING_INDEX, location), - string_(string), start_(start), end_(end) + string_(string), start_(start), end_(end), is_flattened_(false) { } // Return the string being indexed. @@ -3203,6 +3206,8 @@ class String_index_expression : public Expression // The end index of a slice. This may be NULL for a single index, // or it may be a nil expression for the length of the string. Expression* end_; + // Whether this has already been flattened. + bool is_flattened_; }; // An index into a map. |