invalid.carbon 1.1 KB

12345678910111213141516171819202122232425262728293031
  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/class/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/class/invalid.carbon
  12. // --- fail_invalid_base.carbon
  13. library "[[@TEST_NAME]]";
  14. import Cpp inline '''
  15. struct Base {
  16. // CHECK:STDERR: fail_invalid_base.carbon:[[@LINE+4]]:3: error: unknown type name 'no_such_type' [CppInteropParseError]
  17. // CHECK:STDERR: 10 | no_such_type invalid;
  18. // CHECK:STDERR: | ^
  19. // CHECK:STDERR:
  20. no_such_type invalid;
  21. };
  22. struct Derived : Base {};
  23. ''';
  24. // Use of an invalid class should not cause the toolchain to crash or produce
  25. // redundant diagnostics.
  26. var x: Cpp.Derived;