fail_flush_errors.carbon 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. "undec\x6Cared2";
  27. // CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: name `undeclared2` not found [NameNotFound]
  28. // CHECK:STDERR: undeclared2;
  29. // CHECK:STDERR: ^~~~~~~~~~~
  30. // CHECK:STDERR:
  31. undeclared2;
  32. // Add the name into the string table via a declaration rather than an expression.
  33. if (true) { let undeclared3:! () = (); }
  34. // CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: name `undeclared3` not found [NameNotFound]
  35. // CHECK:STDERR: undeclared3;
  36. // CHECK:STDERR: ^~~~~~~~~~~
  37. // CHECK:STDERR:
  38. undeclared3;
  39. }