]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
compiler: tweaks for importing inline function bodies
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Nov 2018 23:46:38 +0000 (23:46 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Nov 2018 23:46:38 +0000 (23:46 +0000)
    Track whether we've seen an error when importing a function; we will
    use error tracking to avoid knock-on errors.

    Stop importing identifiers at a ')'.

    Provide a way to adjust the indentation level while importing.

    Reviewed-on: https://go-review.googlesource.com/c/150072

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266536 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/import.cc
gcc/go/gofrontend/import.h

index 9ce86dea723bf042d44fe6a9832328adf33773af..8e220f50bf6e4744ea271588b5bfa383f178d66a 100644 (file)
@@ -1,4 +1,4 @@
-267d91b41571329e71a88f56df46444b305482da
+b013405f2c66596c47cb9be493c798db1087c0f0
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index eefee7cb1e62402586adc0feeae14dcced715e07..d783043ec04514e244a34537f2e2a23861129a97 100644 (file)
@@ -1225,7 +1225,7 @@ Import::read_identifier()
   while (true)
     {
       c = stream->peek_char();
-      if (c == -1 || c == ' ' || c == '\n' || c == ';')
+      if (c == -1 || c == ' ' || c == '\n' || c == ';' || c == ')')
        break;
       ret += c;
       stream->advance(1);
@@ -1450,7 +1450,7 @@ Import_function_body::read_identifier()
   for (size_t i = start; i < this->body_.length(); i++)
     {
       int c = static_cast<unsigned char>(this->body_[i]);
-      if (c == ' ' || c == '\n' || c == ';')
+      if (c == ' ' || c == '\n' || c == ';' || c == ')')
        {
          this->off_ = i;
          return this->body_.substr(start, i - start);
index e2f4e50378ca79c2f2aeb98e537068d76d840d45..c46a37e0ce96278136a38231fe79f22718200041 100644 (file)
@@ -554,7 +554,7 @@ class Import_function_body : public Import_expression
                       const std::string& body, size_t off, Block* block,
                       int indent)
     : gogo_(gogo), imp_(imp), named_object_(named_object), body_(body),
-      off_(off), block_(block), indent_(indent)
+      off_(off), block_(block), indent_(indent), saw_error_(false)
   { }
 
   // The IR.
@@ -597,6 +597,16 @@ class Import_function_body : public Import_expression
   indent() const
   { return this->indent_; }
 
+  // Increment the indentation level.
+  void
+  increment_indent()
+  { ++this->indent_; }
+
+  // Decrement the indentation level.
+  void
+  decrement_indent()
+  { --this->indent_; }
+
   // The name of the function we are parsing.
   const std::string&
   name() const;
@@ -652,6 +662,16 @@ class Import_function_body : public Import_expression
   ifb()
   { return this; }
 
+  // Return whether we have seen an error.
+  bool
+  saw_error() const
+  { return this->saw_error_; }
+
+  // Record that we have seen an error.
+  void
+  set_saw_error()
+  { this->saw_error_ = true; }
+
  private:
   // The IR.
   Gogo* gogo_;