mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:21:21 +01:00
Recover better from invalid C++ classes. (#5992)
When importing a class definition, don't ask for the class layout if the definition is invalid. Avoids an assertion failure in Clang. --------- Co-authored-by: Dana Jansens <danakj@orodu.net>
This commit is contained in:
co-authored by
Dana Jansens
parent
00d0eb85e2
commit
4483d1e5a7
@@ -0,0 +1,27 @@
|
||||
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// TIP: To test this file alone, run:
|
||||
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/enum/invalid.carbon
|
||||
// TIP: To dump output, run:
|
||||
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/enum/invalid.carbon
|
||||
|
||||
// --- fail_invalid_underlying_type.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
import Cpp inline '''
|
||||
// CHECK:STDERR: fail_invalid_underlying_type.carbon:[[@LINE+4]]:20: error: unknown type name 'no_such_type' [CppInteropParseError]
|
||||
// CHECK:STDERR: 9 | enum InvalidEnum : no_such_type {};
|
||||
// CHECK:STDERR: | ^
|
||||
// CHECK:STDERR:
|
||||
enum InvalidEnum : no_such_type {};
|
||||
''';
|
||||
|
||||
// Use of an invalid enum should not cause the toolchain to crash or produce
|
||||
// redundant diagnostics.
|
||||
var x: Cpp.InvalidEnum;
|
||||
Reference in New Issue
Block a user