fail_postincrement.carbon 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. var n: i32 = 0;
  8. // TODO: It'd be nice to produce a custom diagnostic here.
  9. // CHECK:STDERR: fail_postincrement.carbon:[[@LINE+3]]:4: Expected `;` after expression statement.
  10. // CHECK:STDERR: n++;
  11. // CHECK:STDERR: ^
  12. n++;
  13. // CHECK:STDERR: fail_postincrement.carbon:[[@LINE+3]]:4: Expected `;` after expression statement.
  14. // CHECK:STDERR: n--;
  15. // CHECK:STDERR: ^
  16. n--;
  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: 'VariableIntroducer', text: 'var'},
  25. // CHECK:STDOUT: {kind: 'Name', text: 'n'},
  26. // CHECK:STDOUT: {kind: 'Literal', text: 'i32'},
  27. // CHECK:STDOUT: {kind: 'PatternBinding', text: ':', subtree_size: 3},
  28. // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
  29. // CHECK:STDOUT: {kind: 'Literal', text: '0'},
  30. // CHECK:STDOUT: {kind: 'VariableDeclaration', text: ';', subtree_size: 7},
  31. // CHECK:STDOUT: {kind: 'NameExpression', text: 'n'},
  32. // CHECK:STDOUT: {kind: 'ExpressionStatement', text: ';', has_error: yes, subtree_size: 2},
  33. // CHECK:STDOUT: {kind: 'NameExpression', text: 'n'},
  34. // CHECK:STDOUT: {kind: 'ExpressionStatement', text: ';', has_error: yes, subtree_size: 2},
  35. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 17},
  36. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  37. // CHECK:STDOUT: ]