fail_top_level_if.carbon 1.8 KB

123456789101112131415161718192021222324252627282930313233343536
  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: 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: 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: 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: [
  19. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  20. // CHECK:STDOUT: {kind: 'Name', text: 'F'},
  21. // CHECK:STDOUT: {kind: 'ParameterListStart', text: '('},
  22. // CHECK:STDOUT: {kind: 'ParameterList', text: ')', subtree_size: 2},
  23. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
  24. // CHECK:STDOUT: {kind: 'IfConditionStart', text: 'if', has_error: yes},
  25. // CHECK:STDOUT: {kind: 'Literal', text: 'true'},
  26. // CHECK:STDOUT: {kind: 'IfCondition', text: 'if', has_error: yes, subtree_size: 3},
  27. // CHECK:STDOUT: {kind: 'CodeBlockStart', text: 'then', has_error: yes},
  28. // CHECK:STDOUT: {kind: 'InvalidParse', text: 'then', has_error: yes},
  29. // CHECK:STDOUT: {kind: 'ExpressionStatement', text: ';', has_error: yes, subtree_size: 2},
  30. // CHECK:STDOUT: {kind: 'CodeBlock', text: 'then', has_error: yes, subtree_size: 4},
  31. // CHECK:STDOUT: {kind: 'IfStatement', text: 'if', subtree_size: 8},
  32. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 14},
  33. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  34. // CHECK:STDOUT: ]