fail_errors.carbon 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/parse/testdata/if/fail_errors.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/if/fail_errors.carbon
  10. fn F() {
  11. // CHECK:STDERR: fail_errors.carbon:[[@LINE+4]]:6: error: expected `(` after `if` [ExpectedParenAfter]
  12. // CHECK:STDERR: if a {}
  13. // CHECK:STDERR: ^
  14. // CHECK:STDERR:
  15. if a {}
  16. // CHECK:STDERR: fail_errors.carbon:[[@LINE+4]]:7: error: expected expression [ExpectedExpr]
  17. // CHECK:STDERR: if () {}
  18. // CHECK:STDERR: ^
  19. // CHECK:STDERR:
  20. if () {}
  21. // CHECK:STDERR: fail_errors.carbon:[[@LINE+4]]:9: error: unexpected tokens before `)` [ExpectedCloseSymbol]
  22. // CHECK:STDERR: if (b c) {}
  23. // CHECK:STDERR: ^
  24. // CHECK:STDERR:
  25. if (b c) {}
  26. if (d)
  27. // CHECK:STDERR: fail_errors.carbon:[[@LINE+8]]:1: error: expected braced code block [ExpectedCodeBlock]
  28. // CHECK:STDERR: }
  29. // CHECK:STDERR: ^
  30. // CHECK:STDERR:
  31. // CHECK:STDERR: fail_errors.carbon:[[@LINE+4]]:1: error: expected expression [ExpectedExpr]
  32. // CHECK:STDERR: }
  33. // CHECK:STDERR: ^
  34. // CHECK:STDERR:
  35. }
  36. // CHECK:STDOUT: - filename: fail_errors.carbon
  37. // CHECK:STDOUT: parse_tree: [
  38. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  39. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  40. // CHECK:STDOUT: {kind: 'IdentifierNameBeforeParams', text: 'F'},
  41. // CHECK:STDOUT: {kind: 'ExplicitParamListStart', text: '('},
  42. // CHECK:STDOUT: {kind: 'ExplicitParamList', text: ')', subtree_size: 2},
  43. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
  44. // CHECK:STDOUT: {kind: 'IfConditionStart', text: 'if', has_error: yes},
  45. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'a'},
  46. // CHECK:STDOUT: {kind: 'IfCondition', text: 'if', has_error: yes, subtree_size: 3},
  47. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  48. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
  49. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
  50. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  51. // CHECK:STDOUT: {kind: 'InvalidParse', text: ')', has_error: yes},
  52. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', has_error: yes, subtree_size: 3},
  53. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  54. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
  55. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
  56. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  57. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'b'},
  58. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', has_error: yes, subtree_size: 3},
  59. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '{'},
  60. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', subtree_size: 2},
  61. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 6},
  62. // CHECK:STDOUT: {kind: 'IfConditionStart', text: '('},
  63. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'd'},
  64. // CHECK:STDOUT: {kind: 'IfCondition', text: ')', subtree_size: 3},
  65. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: '}', has_error: yes},
  66. // CHECK:STDOUT: {kind: 'InvalidParse', text: '}', has_error: yes},
  67. // CHECK:STDOUT: {kind: 'ExprStatement', text: ')', has_error: yes, subtree_size: 2},
  68. // CHECK:STDOUT: {kind: 'CodeBlock', text: '}', has_error: yes, subtree_size: 4},
  69. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 8},
  70. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 32},
  71. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  72. // CHECK:STDOUT: ]