<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - FileCheck's --implicit-check-not doesn't flag the unexpected string after a CHECK-DAG"
   href="https://bugs.llvm.org/show_bug.cgi?id=45629">45629</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>FileCheck's --implicit-check-not doesn't flag the unexpected string after a CHECK-DAG
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Test Suite
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>lit
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mboehme@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>daniel@zuster.org, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>FileCheck's `--implicit-check-not` doesn't flag the unexpected string if it
occurs after a string that was matched by a `CHECK-DAG`.

I'm not sure if this is expected behavior, but it certainly seems very
unintuitive. I suspect there may be a number of tests out there that aren't
testing what they think they're testing -- after all, an `--implicit-check-not`
that silently isn't doing anything is not going to be noticed.

I observe this behavior at git commit 5e4413896d6349a923665af2dbdae6253e8dac59
(of April 18, 2020).

To reproduce:

Create a file `check_file.txt` with the following content:

CHECK: expected
CHECK-DAG: dag1
CHECK-DAG: dag2

Ensure `FileCheck` is on the path, then run

echo expected dag1 unexpected dag2 | FileCheck check_file.txt
--implicit-check-not=unexpected
echo expected dag1 dag2 unexpected | FileCheck check_file.txt
--implicit-check-not=unexpected

Actual behavior:
`FileCheck` doesn't report any errors.

Expected behavior:
`FileCheck` should report an error for the occurence of "unexpected" in the
input.

Note:
If "unexpected" occurs in the input before the string matched by the first
`CHECK-DAG`, the behavior is as expected:

$ echo expected unexpected dag1 dag2 | FileCheck check_file.txt
--implicit-check-not=unexpected
command line:1:22: error: CHECK-NOT: excluded string found in input
-implicit-check-not='unexpected'
                     ^
<stdin>:1:10: note: found here
expected unexpected dag1 dag2</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>