fail_unbraced.carbon 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. // TODO: This should have an error.
  6. // AUTOUPDATE
  7. // TIP: To test this file alone, run:
  8. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/parse/testdata/if/fail_unbraced.carbon
  9. // TIP: To dump output, run:
  10. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/if/fail_unbraced.carbon
  11. fn F() {
  12. if (a)
  13. // CHECK:STDERR: fail_unbraced.carbon:[[@LINE+4]]:5: error: expected braced code block [ExpectedCodeBlock]
  14. // CHECK:STDERR: if (b)
  15. // CHECK:STDERR: ^~
  16. // CHECK:STDERR:
  17. if (b)
  18. // CHECK:STDERR: fail_unbraced.carbon:[[@LINE+4]]:7: error: expected braced code block [ExpectedCodeBlock]
  19. // CHECK:STDERR: if (c)
  20. // CHECK:STDERR: ^~
  21. // CHECK:STDERR:
  22. if (c)
  23. // CHECK:STDERR: fail_unbraced.carbon:[[@LINE+4]]:9: error: expected braced code block [ExpectedCodeBlock]
  24. // CHECK:STDERR: d;
  25. // CHECK:STDERR: ^
  26. // CHECK:STDERR:
  27. d;
  28. }
  29. // CHECK:STDOUT: - filename: fail_unbraced.carbon
  30. // CHECK:STDOUT: parse_tree: [
  31. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  32. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  33. // CHECK:STDOUT: {kind: 'IdentifierNameBeforeParams', text: 'F'},
  34. // CHECK:STDOUT: {kind: 'ExplicitParamListStart', text: '('},
  35. // CHECK:STDOUT: {kind: 'ExplicitParamList', text: ')', subtree_size: 2},
  36. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
  37. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  38. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'a'},
  39. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', subtree_size: 3},
  40. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: 'if', has_error: yes},
  41. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  42. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'b'},
  43. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', subtree_size: 3},
  44. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: 'if', has_error: yes},
  45. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  46. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'c'},
  47. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', subtree_size: 3},
  48. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: 'd', has_error: yes},
  49. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'd'},
  50. // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', subtree_size: 2},
  51. // CHECK:STDOUT: {kind: 'CodeBlock', text: 'd', has_error: yes, subtree_size: 4},
  52. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 8},
  53. // CHECK:STDOUT: {kind: 'CodeBlock', text: 'if', has_error: yes, subtree_size: 10},
  54. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 14},
  55. // CHECK:STDOUT: {kind: 'CodeBlock', text: 'if', has_error: yes, subtree_size: 16},
  56. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 20},
  57. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 26},
  58. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  59. // CHECK:STDOUT: ]