[flang] fix previous changes after testing
authorpeter klausler <pklausler@nvidia.com>
Wed, 9 May 2018 23:06:57 +0000 (16:06 -0700)
committerpeter klausler <pklausler@nvidia.com>
Wed, 9 May 2018 23:06:57 +0000 (16:06 -0700)
Original-commit: flang-compiler/f18@c088704f135cdb27cf13b5961ee1563ea2389aef
Reviewed-on: https://github.com/flang-compiler/f18/pull/85
Tree-same-pre-rewrite: false

flang/lib/parser/prescan.cc

index 0896d35..cf76ccb 100644 (file)
@@ -735,9 +735,9 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) {
   if (p >= limit_) {
     return nullptr;
   }
+  for (; *p == ' ' || *p == '\t'; ++p) {
+  }
   if (directiveSentinel_ != nullptr) {
-    for (; *p == ' ' || *p == '\t'; ++p) {
-    }
     if (*p++ != '!') {
       return nullptr;
     }
@@ -749,22 +749,26 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) {
     for (; *p == ' ' || *p == '\t'; ++p) {
     }
     if (*p == '&') {
-      ++p;
-    } else if (!ampersand) {
+      return p + 1;
+    } else if (ampersand) {
+      return p;
+    } else {
       return nullptr;
     }
   } else {
     if (*p == '&') {
-      ++p;
+      return p + 1;
+    } else if (*p == '!' || *p == '\n') {
+      return nullptr;
     } else if (ampersand || delimiterNesting_ > 0) {
       if (p > lineStart_) {
         --p;
       }
+      return p;
     } else {
       return nullptr;
     }
   }
-  return p;
 }
 
 bool Prescanner::FixedFormContinuation() {