fail_postincrement.carbon 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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/operators/fail_postincrement.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/parse/testdata/operators/fail_postincrement.carbon
  10. fn F() {
  11. var n: i32 = 0;
  12. // TODO: It'd be nice to produce a custom diagnostic here.
  13. // CHECK:STDERR: fail_postincrement.carbon:[[@LINE+4]]:4: ERROR: Expected `;` after expression statement.
  14. // CHECK:STDERR: n++;
  15. // CHECK:STDERR: ^~
  16. // CHECK:STDERR:
  17. n++;
  18. // CHECK:STDERR: fail_postincrement.carbon:[[@LINE+3]]:4: ERROR: Expected `;` after expression statement.
  19. // CHECK:STDERR: n--;
  20. // CHECK:STDERR: ^~
  21. n--;
  22. }
  23. // CHECK:STDOUT: - filename: fail_postincrement.carbon
  24. // CHECK:STDOUT: parse_tree: [
  25. // CHECK:STDOUT: {kind: 'FileStart', text: ''},
  26. // CHECK:STDOUT: {kind: 'FunctionIntroducer', text: 'fn'},
  27. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'F'},
  28. // CHECK:STDOUT: {kind: 'TuplePatternStart', text: '('},
  29. // CHECK:STDOUT: {kind: 'TuplePattern', text: ')', subtree_size: 2},
  30. // CHECK:STDOUT: {kind: 'FunctionDefinitionStart', text: '{', subtree_size: 5},
  31. // CHECK:STDOUT: {kind: 'VariableIntroducer', text: 'var'},
  32. // CHECK:STDOUT: {kind: 'IdentifierName', text: 'n'},
  33. // CHECK:STDOUT: {kind: 'IntTypeLiteral', text: 'i32'},
  34. // CHECK:STDOUT: {kind: 'BindingPattern', text: ':', subtree_size: 3},
  35. // CHECK:STDOUT: {kind: 'VariableInitializer', text: '='},
  36. // CHECK:STDOUT: {kind: 'IntLiteral', text: '0'},
  37. // CHECK:STDOUT: {kind: 'VariableDecl', text: ';', subtree_size: 7},
  38. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'},
  39. // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', has_error: yes, subtree_size: 2},
  40. // CHECK:STDOUT: {kind: 'IdentifierNameExpr', text: 'n'},
  41. // CHECK:STDOUT: {kind: 'ExprStatement', text: ';', has_error: yes, subtree_size: 2},
  42. // CHECK:STDOUT: {kind: 'FunctionDefinition', text: '}', subtree_size: 17},
  43. // CHECK:STDOUT: {kind: 'FileEnd', text: ''},
  44. // CHECK:STDOUT: ]