invalid.carbon 1.1 KB

123456789101112131415161718192021222324252627
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/enum/invalid.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/enum/invalid.carbon
  12. // --- fail_invalid_underlying_type.carbon
  13. library "[[@TEST_NAME]]";
  14. import Cpp inline '''
  15. // CHECK:STDERR: fail_invalid_underlying_type.carbon:[[@LINE+4]]:20: error: unknown type name 'no_such_type' [CppInteropParseError]
  16. // CHECK:STDERR: 9 | enum InvalidEnum : no_such_type {};
  17. // CHECK:STDERR: | ^
  18. // CHECK:STDERR:
  19. enum InvalidEnum : no_such_type {};
  20. ''';
  21. // Use of an invalid enum should not cause the toolchain to crash or produce
  22. // redundant diagnostics.
  23. var x: Cpp.InvalidEnum;