fail_flush_errors.carbon 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. // INCLUDE-FILE: toolchain/testing/min_prelude/destroy.carbon
  6. // ARGS: --include-diagnostic-kind compile --custom-core %s
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/driver/testdata/fail_flush_errors.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/driver/testdata/fail_flush_errors.carbon
  13. fn F() {
  14. // Create diagnostics containing string references, and trigger reallocation
  15. // of the string table.
  16. // CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: name `undeclared1` not found [NameNotFound]
  17. // CHECK:STDERR: undeclared1;
  18. // CHECK:STDERR: ^~~~~~~~~~~
  19. // CHECK:STDERR:
  20. undeclared1;
  21. // Add the name into the string table from the tokenized buffer's string
  22. // literal storage. Use a hex escape to ensure that the tokenized buffer
  23. // allocates separate storage for the result.
  24. "undec\x6Cared2";
  25. // CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: name `undeclared2` not found [NameNotFound]
  26. // CHECK:STDERR: undeclared2;
  27. // CHECK:STDERR: ^~~~~~~~~~~
  28. // CHECK:STDERR:
  29. undeclared2;
  30. // Add the name into the string table via a declaration rather than an expression.
  31. if (true) { var undeclared3: () = (); }
  32. // CHECK:STDERR: fail_flush_errors.carbon:[[@LINE+4]]:3: error: name `undeclared3` not found [NameNotFound]
  33. // CHECK:STDERR: undeclared3;
  34. // CHECK:STDERR: ^~~~~~~~~~~
  35. // CHECK:STDERR:
  36. undeclared3;
  37. }