fail_postincrement.carbon 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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+4]]:4: ERROR: Expected `;` after expression statement.
  10. // CHECK:STDERR: n++;
  11. // CHECK:STDERR: ^~
  12. // CHECK:STDERR:
  13. n++;
  14. // CHECK:STDERR: fail_postincrement.carbon:[[@LINE+3]]:4: ERROR: Expected `;` after expression statement.
  15. // CHECK:STDERR: n--;
  16. // CHECK:STDERR: ^~
  17. n--;
  18. }
  19. // CHECK:STDOUT: - filename: fail_postincrement.carbon
  20. // CHECK:STDOUT: parse_tree: [
  21. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  22. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  23. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'F'},
  24. // CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('},
  25. // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2},
  26. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
  27. // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
  28. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'n'},
  29. // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
  30. // CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3},
  31. // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
  32. // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
  33. // CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7},
  34. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'},
  35. // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', has_error: yes, subtree_size: 2},
  36. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'},
  37. // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', has_error: yes, subtree_size: 2},
  38. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 17},
  39. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  40. // CHECK:STDOUT: ]