fail_bad_condition.carbon 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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_bad_condition.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/while/fail_bad_condition.carbon
  10. fn While() {
  11. // CHECK:STDERR: fail_bad_condition.carbon:[[@LINE+3]]:9: ERROR: Cannot implicitly convert from `String` to `bool`.
  12. // CHECK:STDERR: while ("Hello") {}
  13. // CHECK:STDERR: ^~~~~~~~~
  14. while ("Hello") {}
  15. }
  16. // CHECK:STDOUT: --- fail_bad_condition.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %While.type: type = fn_type @While [template]
  20. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  21. // CHECK:STDOUT: %While: %While.type = struct_value () [template]
  22. // CHECK:STDOUT: %.2: type = ptr_type String [template]
  23. // CHECK:STDOUT: %.3: String = string_literal "Hello" [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: file {
  27. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  28. // CHECK:STDOUT: .Core = %Core
  29. // CHECK:STDOUT: .While = %While.decl
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  32. // CHECK:STDOUT: %While.decl: %While.type = fn_decl @While [template = constants.%While] {}
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: fn @While() {
  36. // CHECK:STDOUT: !entry:
  37. // CHECK:STDOUT: br !while.cond
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: !while.cond:
  40. // CHECK:STDOUT: %.loc15: String = string_literal "Hello" [template = constants.%.3]
  41. // CHECK:STDOUT: if <error> br !while.body else br !while.done
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: !while.body:
  44. // CHECK:STDOUT: br !while.cond
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: !while.done:
  47. // CHECK:STDOUT: return
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: