fail_flush_errors.carbon 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // This test is validating that the delayed error flush doesn't break on string
  6. // lifetimes.
  7. //
  8. // ARGS: --include-diagnostic-kind compile --no-prelude-import %s
  9. //
  10. // AUTOUPDATE
  11. // TIP: To test this file alone, run:
  12. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/fail_flush_errors.carbon
  13. // TIP: To dump output, run:
  14. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/fail_flush_errors.carbon
  15. fn F() {
  16. // Create diagnostics containing string references, and trigger reallocation
  17. // of the string table.
  18. // CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: name `undeclared1` not found [NameNotFound]
  19. // CHECK:STDERR: undeclared1;
  20. // CHECK:STDERR: ^~~~~~~~~~~
  21. // CHECK:STDERR:
  22. undeclared1;
  23. // Add the name into the string table from the tokenized buffer's string
  24. // literal storage. Use a hex escape to ensure that the tokenized buffer
  25. // allocates separate storage for the result.
  26. // CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: `Core.String` implicitly referenced here, but package `Core` not found [CoreNotFound]
  27. // CHECK:STDERR: "undec\x6Cared2";
  28. // CHECK:STDERR: ^~~~~~~~~~~~~~~~
  29. // CHECK:STDERR:
  30. "undec\x6Cared2";
  31. // CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: name `undeclared2` not found [NameNotFound]
  32. // CHECK:STDERR: undeclared2;
  33. // CHECK:STDERR: ^~~~~~~~~~~
  34. // CHECK:STDERR:
  35. undeclared2;
  36. // Add the name into the string table via a declaration rather than an expression.
  37. if (true) { let undeclared3:! () = (); }
  38. // CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: name `undeclared3` not found [NameNotFound]
  39. // CHECK:STDERR: undeclared3;
  40. // CHECK:STDERR: ^~~~~~~~~~~
  41. // CHECK:STDERR:
  42. undeclared3;
  43. }