fail_break_continue.carbon 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/while/fail_break_continue.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/while/fail_break_continue.carbon
  10. fn While() {
  11. // CHECK:STDERR: fail_break_continue.carbon:[[@LINE+4]]:3: ERROR: `continue` can only be used in a loop.
  12. // CHECK:STDERR: continue;
  13. // CHECK:STDERR: ^~~~~~~~
  14. // CHECK:STDERR:
  15. continue;
  16. // CHECK:STDERR: fail_break_continue.carbon:[[@LINE+4]]:3: ERROR: `break` can only be used in a loop.
  17. // CHECK:STDERR: break;
  18. // CHECK:STDERR: ^~~~~
  19. // CHECK:STDERR:
  20. break;
  21. while (false) {
  22. continue;
  23. break;
  24. }
  25. // CHECK:STDERR: fail_break_continue.carbon:[[@LINE+4]]:3: ERROR: `continue` can only be used in a loop.
  26. // CHECK:STDERR: continue;
  27. // CHECK:STDERR: ^~~~~~~~
  28. // CHECK:STDERR:
  29. continue;
  30. // CHECK:STDERR: fail_break_continue.carbon:[[@LINE+3]]:3: ERROR: `break` can only be used in a loop.
  31. // CHECK:STDERR: break;
  32. // CHECK:STDERR: ^~~~~
  33. break;
  34. }
  35. // CHECK:STDOUT: --- fail_break_continue.carbon
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: constants {
  38. // CHECK:STDOUT: %While.type: type = fn_type @While [template]
  39. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  40. // CHECK:STDOUT: %While: %While.type = struct_value () [template]
  41. // CHECK:STDOUT: %.2: bool = bool_literal false [template]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: file {
  45. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  46. // CHECK:STDOUT: .Core = %Core
  47. // CHECK:STDOUT: .While = %While.decl
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  50. // CHECK:STDOUT: %While.decl: %While.type = fn_decl @While [template = constants.%While] {}
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: fn @While() {
  54. // CHECK:STDOUT: !entry:
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: