fail_top_level_if.carbon 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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_top_level_if.carbon:[[@LINE+9]]:6: ERROR: Expected `(` after `if`.
  8. // CHECK:STDERR: if true then 1 else 2;
  9. // CHECK:STDERR: ^~~~
  10. // CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+6]]:11: ERROR: Expected braced code block.
  11. // CHECK:STDERR: if true then 1 else 2;
  12. // CHECK:STDERR: ^~~~
  13. // CHECK:STDERR: fail_top_level_if.carbon:[[@LINE+3]]:11: ERROR: Expected expression.
  14. // CHECK:STDERR: if true then 1 else 2;
  15. // CHECK:STDERR: ^~~~
  16. if true then 1 else 2;
  17. }
  18. // CHECK:STDOUT: - filename: fail_top_level_if.carbon
  19. // CHECK:STDOUT: parse_tree: [
  20. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  21. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  22. // CHECK:STDOUT: {kind: 'Name', text: 'F'},
  23. // CHECK:STDOUT: {kind: 'ParamListStart', text: '('},
  24. // CHECK:STDOUT: {kind: 'ParamList', text: ')', subtree_size: 2},
  25. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
  26. // CHECK:STDOUT: {kind: 'IfConditionStart', text: 'if', has_error: yes},
  27. // CHECK:STDOUT: {kind: 'BoolLiteralTrue', text: 'true'},
  28. // CHECK:STDOUT: {kind: 'IfCondition', text: 'if', has_error: yes, subtree_size: 3},
  29. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: 'then', has_error: yes},
  30. // CHECK:STDOUT: {kind: 'InvalidParse', text: 'then', has_error: yes},
  31. // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', has_error: yes, subtree_size: 2},
  32. // CHECK:STDOUT: {kind: 'CodeBlock', text: 'then', has_error: yes, subtree_size: 4},
  33. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 8},
  34. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 14},
  35. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  36. // CHECK:STDOUT: ]