fail_errors.carbon 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. fn F() {
  7. // CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:6: Expected `(` after `if`.
  8. // CHECK:STDERR: if a {}
  9. // CHECK:STDERR: ^
  10. if a {}
  11. // CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:7: Expected expression.
  12. // CHECK:STDERR: if () {}
  13. // CHECK:STDERR: ^
  14. if () {}
  15. // CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:9: Unexpected tokens before `)`.
  16. // CHECK:STDERR: if (b c) {}
  17. // CHECK:STDERR: ^
  18. if (b c) {}
  19. if (d)
  20. // CHECK:STDERR: fail_errors.carbon:[[@LINE+6]]:1: Expected braced code block.
  21. // CHECK:STDERR: }
  22. // CHECK:STDERR: ^
  23. // CHECK:STDERR: fail_errors.carbon:[[@LINE+3]]:1: Expected expression.
  24. // CHECK:STDERR: }
  25. // CHECK:STDERR: ^
  26. }
  27. // CHECK:STDOUT: - filename: fail_errors.carbon
  28. // CHECK:STDOUT: parse_tree: [
  29. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  30. // CHECK:STDOUT: {kind: 'Name', text: 'F'},
  31. // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('},
  32. // CHECK:STDOUT: {kind: 'ParameterList', text: ')', subtree_size: 2},
  33. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
  34. // CHECK:STDOUT: {kind: 'IfConditionStart', text: 'if', has_error: yes},
  35. // CHECK:STDOUT: {kind: 'NameExpression', text: 'a'},
  36. // CHECK:STDOUT: {kind: 'IfCondition', text: 'if', has_error: yes, subtree_size: 3},
  37. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  38. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
  39. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
  40. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  41. // CHECK:STDOUT: {kind: 'InvalidParse', text: ')', has_error: yes},
  42. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', has_error: yes, subtree_size: 3},
  43. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  44. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
  45. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
  46. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  47. // CHECK:STDOUT: {kind: 'NameExpression', text: 'b'},
  48. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', has_error: yes, subtree_size: 3},
  49. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  50. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
  51. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
  52. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  53. // CHECK:STDOUT: {kind: 'NameExpression', text: 'd'},
  54. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', subtree_size: 3},
  55. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '}', has_error: yes},
  56. // CHECK:STDOUT: {kind: 'InvalidParse', text: '}', has_error: yes},
  57. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', has_error: yes, subtree_size: 3},
  58. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 7},
  59. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 31},
  60. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  61. // CHECK:STDOUT: ]