fail_flush_errors.carbon 1.7 KB

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