testing/c2rust: new aport

Transpile C99-compliant code to (unsafe) Rust code
https://github.com/immunant/c2rust
This commit is contained in:
Marian Buschsieweke 2022-11-11 14:46:24 +01:00 committed by omni
parent 4dae991873
commit 82a7ed7277
4 changed files with 552 additions and 0 deletions

View file

@ -0,0 +1,232 @@
Link dynamically against libclang
diff -rupN a/c2rust/Cargo.toml b/c2rust/Cargo.toml
--- a/c2rust/Cargo.toml 2024-01-06 22:49:13.145706727 +0100
+++ b/c2rust/Cargo.toml 2024-01-06 22:49:56.895188304 +0100
@@ -31,7 +31,3 @@ time-macros = "=0.2.6"
[build-dependencies]
c2rust-build-paths = { path = "../c2rust-build-paths", version = "0.18.0" }
-
-[features]
-# Force static linking of LLVM
-llvm-static = ["c2rust-transpile/llvm-static"]
diff -rupN a/c2rust-ast-exporter/Cargo.toml b/c2rust-ast-exporter/Cargo.toml
--- a/c2rust-ast-exporter/Cargo.toml 2024-01-06 22:49:13.132373552 +0100
+++ b/c2rust-ast-exporter/Cargo.toml 2024-01-06 22:50:53.591183135 +0100
@@ -24,8 +24,3 @@ clang-sys = "1.3"
cmake = "0.1.49"
env_logger = "0.10"
c2rust-build-paths = { path = "../c2rust-build-paths", version = "0.18.0" }
-
-[features]
-default = []
-# Force static linking of LLVM
-llvm-static = []
diff -rupN a/c2rust-ast-exporter/build.rs b/c2rust-ast-exporter/build.rs
--- a/c2rust-ast-exporter/build.rs 2024-01-06 22:49:13.132373552 +0100
+++ b/c2rust-ast-exporter/build.rs 2024-01-06 22:49:18.425644161 +0100
@@ -147,55 +147,7 @@ fn build_native(llvm_info: &LLVMInfo) {
println!("cargo:rustc-link-search=native={}", llvm_lib_dir);
- // Some distro's, including arch and Fedora, no longer build with
- // BUILD_SHARED_LIBS=ON; programs linking to clang are required to
- // link to libclang-cpp.so instead of individual libraries.
- let use_libclang = if cfg!(target_os = "macos") {
- // We hit an issue linking against the shared libraries for the homebrew
- // version of LLVM 15 because they use a feature (opaque pointers) which
- // are not understood by earlier versions of LLVM so we link against
- // libclang unless static linking has been explicitly requested.
- !cfg!(feature = "llvm-static")
- } else {
- // target_os = "linux"
- let mut libclang_path = PathBuf::new();
- libclang_path.push(llvm_lib_dir);
- libclang_path.push("libclang-cpp.so");
- libclang_path.exists()
- };
-
- if use_libclang {
- println!("cargo:rustc-link-lib=clang-cpp");
- } else {
- // Link against these Clang libs. The ordering here is important! Libraries
- // must be listed before their dependencies when statically linking.
- let mut clang_libs = vec![
- "clangTooling",
- "clangFrontend",
- "clangASTMatchers",
- "clangParse",
- "clangSerialization",
- "clangSema",
- "clangEdit",
- "clangAnalysis",
- "clangDriver",
- "clangFormat",
- "clangToolingCore",
- "clangAST",
- "clangRewrite",
- "clangLex",
- "clangBasic",
- ];
- if llvm_info.llvm_major_version >= 15 {
- // insert after clangSema
- let sema_pos = clang_libs.iter().position(|&r| r == "clangSema").unwrap();
- clang_libs.insert(sema_pos + 1, "clangSupport");
- }
-
- for lib in &clang_libs {
- println!("cargo:rustc-link-lib={}", lib);
- }
- }
+ println!("cargo:rustc-link-lib=clang-cpp");
for lib in &llvm_info.libs {
// IMPORTANT: We cannot specify static= or dylib= here because rustc
diff -rupN a/c2rust-ast-exporter/src/CMakeLists.txt b/c2rust-ast-exporter/src/CMakeLists.txt
--- a/c2rust-ast-exporter/src/CMakeLists.txt 2024-01-06 22:49:13.132373552 +0100
+++ b/c2rust-ast-exporter/src/CMakeLists.txt 2024-01-06 22:49:18.425644161 +0100
@@ -95,11 +95,7 @@ set_target_properties(c2rust-ast-exporte
# PRIVATE was added to make c2rust-ast-exporter build with LLVM 6.0. Keyword
# description: https://cmake.org/pipermail/cmake/2016-May/063400.html
target_link_libraries(c2rust-ast-exporter PRIVATE
- clangAST
- clangFrontend
- clangTooling
- clangBasic
- clangASTMatchers
+ clang-cpp
tinycbor
)
diff -rupN a/c2rust-ast-exporter/src/CMakeLists.txt.orig b/c2rust-ast-exporter/src/CMakeLists.txt.orig
--- a/c2rust-ast-exporter/src/CMakeLists.txt.orig 1970-01-01 01:00:00.000000000 +0100
+++ b/c2rust-ast-exporter/src/CMakeLists.txt.orig 2023-05-22 22:14:35.000000000 +0200
@@ -0,0 +1,117 @@
+cmake_minimum_required(VERSION 3.4.3)
+project(ASTExporter)
+
+#################################################
+# TinyCBOR #
+#################################################
+
+set(TINYCBOR_REPO "https://github.com/intel/tinycbor.git" CACHE STRING "tinycbor git repo URL")
+
+# v0.6.3 tag, but using the commit hash instead (of the tarball hash) for integrity checks
+# unlike a .tar.gz MD5 hash, this SHA-1 commit hash should stay stable regardless of compression/archiving
+# (GitHub has changed this), and still retains the integrity check
+set(TINYCBOR_TAG "d393c16f3eb30d0c47e6f9d92db62272f0ec4dc7" CACHE STRING "tinycbor git tag/branch/commit hash")
+
+set(TINYCBOR_PREFIX "${CMAKE_BINARY_DIR}/tinycbor" CACHE STRING "tinycbor install prefix")
+
+if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+ set(MAKE "gmake")
+else()
+ set(MAKE "make")
+endif()
+
+include(ExternalProject)
+ExternalProject_Add(tinycbor_build
+ PREFIX ${TINYCBOR_PREFIX}
+ INSTALL_DIR ${CMAKE_BINARY_DIR}
+ GIT_REPOSITORY ${TINYCBOR_REPO}
+ GIT_TAG ${TINYCBOR_TAG}
+ # the fd redirection here fails when the build run inside Cargo.
+ # patch from upstream:
+ # https://github.com/intel/tinycbor/commit/6176e0a28d7c5ef3a5e9cbd02521999c412de72c
+ PATCH_COMMAND patch --forward -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/tinycbor_fix_build.patch || true
+ CONFIGURE_COMMAND ${MAKE} .config && cat ${CMAKE_CURRENT_SOURCE_DIR}/tinycbor.config >> .config
+ BUILD_COMMAND ${MAKE} --quiet prefix=<INSTALL_DIR> CFLAGS=-fPIC
+ INSTALL_COMMAND ${MAKE} --quiet prefix=<INSTALL_DIR> install
+ BUILD_IN_SOURCE 1
+ BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/lib/libtinycbor.a
+)
+
+include_directories(${CMAKE_BINARY_DIR}/include)
+
+add_library(tinycbor STATIC IMPORTED)
+set_target_properties(tinycbor PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/lib/libtinycbor.a)
+add_dependencies(tinycbor tinycbor_build)
+
+set(AST_EXPORTER_SRCS
+ AstExporter.cpp
+ FloatingLexer.cpp
+ ExportResult.cpp
+ )
+
+set(AST_EXPORTER_BIN_SRCS
+ ${AST_EXPORTER_SRCS}
+ Main.cpp
+ )
+
+find_package(LLVM REQUIRED CONFIG)
+
+# Debian and Ubuntu's clang cmake files are broken, so we can't require the
+# package here. We already have to manually order the link against the clang
+# libs in build.rs, so that's not so bad.
+find_package(Clang CONFIG)
+
+include_directories(${LLVM_INCLUDE_DIRS} ${CLANG_INCLUDE_DIRS})
+add_definitions(${LLVM_DEFINITIONS} ${CLANG_DEFINITIONS})
+
+if (DEFINED CLANG_INSTALL_PREFIX)
+ add_definitions(-DCLANG_BIN_PATH="${CLANG_INSTALL_PREFIX}/bin")
+elseif(DEFINED LLVM_INSTALL_PREFIX)
+ add_definitions(-DCLANG_BIN_PATH="${LLVM_INSTALL_PREFIX}/bin")
+elseif(DEFINED LLVM_TOOLS_BINARY_DIR)
+ add_definitions(-DCLANG_BIN_PATH="${LLVM_TOOLS_BINARY_DIR}")
+else()
+ message(FATAL_ERROR "Cannot find path to clang binary")
+endif()
+add_definitions(-DCLANG_VERSION_STRING="${LLVM_PACKAGE_VERSION}")
+
+set(LLVM_LINK_COMPONENTS support)
+
+# LLVM is not always built with RTTI, we don't need it either.
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
+
+# The executable
+add_executable(c2rust-ast-exporter ${AST_EXPORTER_BIN_SRCS})
+
+# The library
+add_library(clangAstExporter STATIC ${AST_EXPORTER_SRCS})
+
+add_definitions(-DCLANG_LIBDIR_SUFFIX="${LLVM_LIBDIR_SUFFIX}")
+
+set_target_properties(c2rust-ast-exporter PROPERTIES
+ CXX_STANDARD 14
+ CXX_EXTENSIONS OFF
+ )
+# PRIVATE was added to make c2rust-ast-exporter build with LLVM 6.0. Keyword
+# description: https://cmake.org/pipermail/cmake/2016-May/063400.html
+target_link_libraries(c2rust-ast-exporter PRIVATE
+ clangAST
+ clangFrontend
+ clangTooling
+ clangBasic
+ clangASTMatchers
+ tinycbor
+ )
+
+set_target_properties(clangAstExporter PROPERTIES
+ CXX_STANDARD 17 # will decay to 14 if compiler doesn't support c++17
+ CXX_EXTENSIONS OFF
+ )
+target_link_libraries(clangAstExporter PRIVATE
+ clangAST
+ clangFrontend
+ clangTooling
+ clangBasic
+ clangASTMatchers
+ tinycbor
+ )
diff -rupN a/c2rust-transpile/Cargo.toml b/c2rust-transpile/Cargo.toml
--- a/c2rust-transpile/Cargo.toml 2024-01-06 22:49:13.145706727 +0100
+++ b/c2rust-transpile/Cargo.toml 2024-01-06 22:49:18.425644161 +0100
@@ -38,7 +38,3 @@ smallvec = "1.0"
strum = "0.24"
strum_macros = "0.24"
syn = { version = "1.0", features = ["full", "extra-traits", "parsing", "printing"]}
-
-[features]
-# Force static linking of LLVM
-llvm-static = ["c2rust-ast-exporter/llvm-static"]

View file

@ -0,0 +1,64 @@
Use system's tinycbor instead of vendoring it in
diff -rupN a/c2rust-ast-exporter/build.rs b/c2rust-ast-exporter/build.rs
--- a/c2rust-ast-exporter/build.rs 2023-05-22 22:14:35.000000000 +0200
+++ b/c2rust-ast-exporter/build.rs 2024-01-06 22:54:06.039088094 +0100
@@ -142,7 +142,7 @@ fn build_native(llvm_info: &LLVMInfo) {
};
// Statically link against 'clangAstExporter' which requires 'tinycbor'
- println!("cargo:rustc-link-lib=static=tinycbor");
+ println!("cargo:rustc-link-lib=dylib=tinycbor");
println!("cargo:rustc-link-lib=static=clangAstExporter");
println!("cargo:rustc-link-search=native={}", llvm_lib_dir);
diff -rupN a/c2rust-ast-exporter/src/CMakeLists.txt b/c2rust-ast-exporter/src/CMakeLists.txt
--- a/c2rust-ast-exporter/src/CMakeLists.txt 2023-05-22 22:14:35.000000000 +0200
+++ b/c2rust-ast-exporter/src/CMakeLists.txt 2024-01-06 22:55:39.124799597 +0100
@@ -5,14 +5,9 @@ project(ASTExporter)
# TinyCBOR #
#################################################
-set(TINYCBOR_REPO "https://github.com/intel/tinycbor.git" CACHE STRING "tinycbor git repo URL")
-
-# v0.6.3 tag, but using the commit hash instead (of the tarball hash) for integrity checks
-# unlike a .tar.gz MD5 hash, this SHA-1 commit hash should stay stable regardless of compression/archiving
-# (GitHub has changed this), and still retains the integrity check
-set(TINYCBOR_TAG "d393c16f3eb30d0c47e6f9d92db62272f0ec4dc7" CACHE STRING "tinycbor git tag/branch/commit hash")
-
-set(TINYCBOR_PREFIX "${CMAKE_BINARY_DIR}/tinycbor" CACHE STRING "tinycbor install prefix")
+include(FindPkgConfig)
+pkg_search_module(TINYCBOR REQUIRED tinycbor)
+include_directories(${TINYCBOR_INCLUDE_DIRS})
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(MAKE "gmake")
@@ -20,29 +15,6 @@ else()
set(MAKE "make")
endif()
-include(ExternalProject)
-ExternalProject_Add(tinycbor_build
- PREFIX ${TINYCBOR_PREFIX}
- INSTALL_DIR ${CMAKE_BINARY_DIR}
- GIT_REPOSITORY ${TINYCBOR_REPO}
- GIT_TAG ${TINYCBOR_TAG}
- # the fd redirection here fails when the build run inside Cargo.
- # patch from upstream:
- # https://github.com/intel/tinycbor/commit/6176e0a28d7c5ef3a5e9cbd02521999c412de72c
- PATCH_COMMAND patch --forward -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/tinycbor_fix_build.patch || true
- CONFIGURE_COMMAND ${MAKE} .config && cat ${CMAKE_CURRENT_SOURCE_DIR}/tinycbor.config >> .config
- BUILD_COMMAND ${MAKE} --quiet prefix=<INSTALL_DIR> CFLAGS=-fPIC
- INSTALL_COMMAND ${MAKE} --quiet prefix=<INSTALL_DIR> install
- BUILD_IN_SOURCE 1
- BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/lib/libtinycbor.a
-)
-
-include_directories(${CMAKE_BINARY_DIR}/include)
-
-add_library(tinycbor STATIC IMPORTED)
-set_target_properties(tinycbor PROPERTIES IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/lib/libtinycbor.a)
-add_dependencies(tinycbor tinycbor_build)
-
set(AST_EXPORTER_SRCS
AstExporter.cpp
FloatingLexer.cpp

73
testing/c2rust/APKBUILD Normal file
View file

@ -0,0 +1,73 @@
# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
pkgname=c2rust
pkgver=0.18.0
pkgrel=0
pkgdesc="Transpile C99-compliant code to (unsafe) Rust code"
url="https://github.com/immunant/c2rust"
# riscv64: libc crate sup
# s390x: missing big endian support in c2rust-bitfields-derive
# ppc64le: tinycbor not packaged due to segfault in unit tests
arch="all !riscv64 !s390x !ppc64le"
license="BSD-3-Clause"
# Note: LLVM's CMake hooks check for presence of static libs and complain if
# they are missing. So they are needed for building even when linking
# dynamically
makedepends="
cargo
clang17-dev
clang17-static
cmake
libxml2-dev
llvm17-dev
llvm17-gtest
llvm17-static
ncurses-dev
openssl-dev
rust
tinycbor-dev
"
checkdepends="
python3
py3-plumbum
py3-toml
"
source="
$pkgname-$pkgver.tar.gz::https://github.com/immunant/c2rust/archive/refs/tags/v$pkgver.tar.gz
0001-link-clang-dynamic.patch
0002-use-system-tinycbor.patch
df42b55eae9ecfd4380004a513a10526ef8776cf.patch
"
# Unit tests all fail using rust 1.72.1 with:
#
# error[E0554]: #![feature] may not be used on the stable release channel
#
# Eventually, unit tests should also run on stable rust
options="!check"
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_PANIC="abort"
export CARGO_PROFILE_RELEASE_OPT_LEVEL="s"
build() {
cargo build --release --locked --package c2rust
}
check() {
./scripts/test_translator.py tests
}
package() {
mkdir -p "$pkgdir"/usr/bin "$pkgdir"/usr/lib
for bin in c2rust c2rust-transpile; do
install -D -m755 target/release/$bin -t "$pkgdir"/usr/bin/
done
}
sha512sums="
16033110923d22d12c55bdd13aacbeb05b95a54b93b8eabf478b111e99fba6c523102e871f4812d35152a9c02fae39ee25307acdfbe6d7bef23113f5c9db8dde c2rust-0.18.0.tar.gz
3bd7def407277482a33c5074388a10afadf1b40b3f09e2fc87e9942a802b65ca2ee356be56e4baa66d669c57dcfd52ef27d59e740f0c735eb09c03fbf21015bb 0001-link-clang-dynamic.patch
be29e0f4576301b64f5fc38684ddb90e469526be4ce8ef428feee0d5962748c428045dcb81635ff92e132daebb1fa1b338a81ce1ea13d02b802ec057d0653b93 0002-use-system-tinycbor.patch
34764bd19f927bff11e86a26f6826b0875abebfb78256d895d36e04cf16f9a98ac8672ba7de0891613112e3aef724c501045ab303093c3fcad135590c82f3506 df42b55eae9ecfd4380004a513a10526ef8776cf.patch
"

View file

@ -0,0 +1,183 @@
From df42b55eae9ecfd4380004a513a10526ef8776cf Mon Sep 17 00:00:00 2001
From: Per Larsen <perl@immunant.com>
Date: Fri, 3 Nov 2023 16:18:56 -0700
Subject: [PATCH] Add support for LLVM17. Closes #1039.
Also adds extremely limited support for ARMs scalable vector
extension types such that Apple Silicon macs can run unit tests..
---
c2rust-ast-exporter/src/AstExporter.cpp | 27 ++++++++++++++++++++++--
c2rust-ast-exporter/src/ast_tags.hpp | 6 ++++++
c2rust-transpile/src/c_ast/conversion.rs | 9 ++++++++
c2rust-transpile/src/c_ast/iterators.rs | 2 +-
c2rust-transpile/src/c_ast/mod.rs | 4 ++++
c2rust-transpile/src/translator/mod.rs | 3 +++
6 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/c2rust-ast-exporter/src/AstExporter.cpp b/c2rust-ast-exporter/src/AstExporter.cpp
index b58308e51f..fc6e78aec1 100644
--- a/c2rust-ast-exporter/src/AstExporter.cpp
+++ b/c2rust-ast-exporter/src/AstExporter.cpp
@@ -85,6 +85,7 @@ std::string make_realpath(std::string const &path) {
}
// Helper to smooth out differences between versions of clang
+#if CLANG_VERSION_MAJOR < 17
Optional<APSInt> getIntegerConstantExpr(const Expr &E, const ASTContext &Ctx) {
#if CLANG_VERSION_MAJOR < 12
APSInt value;
@@ -96,6 +97,13 @@ Optional<APSInt> getIntegerConstantExpr(const Expr &E, const ASTContext &Ctx) {
return E.getIntegerConstantExpr(Ctx);
#endif // CLANG_VERSION_MAJOR
}
+#else
+#include <optional>
+std::optional<APSInt> getIntegerConstantExpr(const Expr &E,
+ const ASTContext &Ctx) {
+ return E.getIntegerConstantExpr(Ctx);
+}
+#endif // CLANG_VERSION_MAJOR
} // namespace
class TranslateASTVisitor;
@@ -363,7 +371,7 @@ class TypeEncoder final : public TypeVisitor<TypeEncoder> {
}
}();
// All the SVE types present in Clang 10 are 128-bit vectors
- // (see `AArch64SVEACLETypes.def`), so we can divide 128
+ // (see `AArch64SVEACLETypes.def`), so we can divide 128
// by their element size to get element count.
auto ElemCount = 128 / Context->getTypeSize(ElemType);
#endif // CLANG_VERSION_MAJOR >= 11
@@ -403,7 +411,7 @@ class TypeEncoder final : public TypeVisitor<TypeEncoder> {
// Constructed as a consequence of the conversion of
// built-in to normal vector types.
case BuiltinType::Float16: return TagHalf;
- case BuiltinType::Half: return TagHalf;
+ case BuiltinType::Half: return TagHalf;
#if CLANG_VERSION_MAJOR >= 11
case BuiltinType::BFloat16: return TagBFloat16;
#endif
@@ -418,6 +426,12 @@ class TypeEncoder final : public TypeVisitor<TypeEncoder> {
case BuiltinType::Bool: return TagBool;
case BuiltinType::WChar_S: return TagSWChar;
case BuiltinType::WChar_U: return TagUWChar;
+#if CLANG_VERSION_MAJOR >= 16
+ case BuiltinType::SveCount: return TagSveCount;
+ case BuiltinType::SveBool: return TagSveBool;
+ case BuiltinType::SveBoolx2: return TagSveBoolx2;
+ case BuiltinType::SveBoolx4: return TagSveBoolx4;
+#endif
}
}();
@@ -1499,7 +1513,11 @@ class TranslateASTVisitor final
cbor_encoder_create_array(&array, &entry, 2);
cbor_encode_int(&entry, 2);
cbor_encode_uint(&entry,
+#if CLANG_VERSION_MAJOR < 17
uintptr_t(designator.getField()));
+#else
+ uintptr_t(designator.getFieldDecl()));
+#endif // CLANG_VERSION_MAJOR
} else if (designator.isArrayRangeDesignator()) {
cbor_encoder_create_array(&array, &entry, 3);
cbor_encode_int(&entry, 3);
@@ -2300,6 +2318,11 @@ class TranslateASTVisitor final
case clang::StringLiteral::StringKind::UTF32:
cbor_encode_uint(array, StringTypeTag::TagUTF32);
break;
+#if CLANG_VERSION_MAJOR >= 17
+ case clang::StringLiteral::StringKind::Unevaluated:
+ cbor_encode_uint(array, StringTypeTag::TagUnevaluated);
+ break;
+#endif // CLANG_VERSION_MAJOR
}
// The size of the wchar_t type in C is implementation defined
cbor_encode_uint(array, SL->getCharByteWidth());
diff --git a/c2rust-ast-exporter/src/ast_tags.hpp b/c2rust-ast-exporter/src/ast_tags.hpp
index ab6e87344b..2027957d5f 100644
--- a/c2rust-ast-exporter/src/ast_tags.hpp
+++ b/c2rust-ast-exporter/src/ast_tags.hpp
@@ -142,6 +142,11 @@ enum TypeTag {
TagComplexType,
TagHalf,
TagBFloat16,
+
+ TagSveCount,
+ TagSveBool,
+ TagSveBoolx2,
+ TagSveBoolx4,
};
enum StringTypeTag {
@@ -150,6 +155,7 @@ enum StringTypeTag {
TagUTF8,
TagUTF16,
TagUTF32,
+ TagUnevaluated,
};
// From `clang/Basic/TargetInfo.h`
diff --git a/c2rust-transpile/src/c_ast/conversion.rs b/c2rust-transpile/src/c_ast/conversion.rs
index 26033bf0ae..3fe769fca5 100644
--- a/c2rust-transpile/src/c_ast/conversion.rs
+++ b/c2rust-transpile/src/c_ast/conversion.rs
@@ -804,6 +804,15 @@ impl ConversionContext {
self.processed_nodes.insert(new_id, OTHER_TYPE);
}
+ TypeTag::TagSveCount
+ | TypeTag::TagSveBool
+ | TypeTag::TagSveBoolx2
+ | TypeTag::TagSveBoolx4 => {
+ let ty = CTypeKind::UnhandledSveType;
+ self.add_type(new_id, not_located(ty));
+ self.processed_nodes.insert(new_id, OTHER_TYPE);
+ }
+
TypeTag::TagVectorType => {
let elt =
from_value(ty_node.extras[0].clone()).expect("Vector child not found");
diff --git a/c2rust-transpile/src/c_ast/iterators.rs b/c2rust-transpile/src/c_ast/iterators.rs
index 6817cf1e1a..22ba07e71c 100644
--- a/c2rust-transpile/src/c_ast/iterators.rs
+++ b/c2rust-transpile/src/c_ast/iterators.rs
@@ -285,7 +285,7 @@ fn immediate_type_children(kind: &CTypeKind) -> Vec<SomeId> {
TypeOfExpr(e) => intos![e],
Void | Bool | Short | Int | Long | LongLong | UShort | UInt | ULong | ULongLong | SChar
| UChar | Char | Double | LongDouble | Float | Int128 | UInt128 | BuiltinFn | Half
- | BFloat16 => {
+ | BFloat16 | UnhandledSveType => {
vec![]
}
diff --git a/c2rust-transpile/src/c_ast/mod.rs b/c2rust-transpile/src/c_ast/mod.rs
index 56b067f3e8..182b795812 100644
--- a/c2rust-transpile/src/c_ast/mod.rs
+++ b/c2rust-transpile/src/c_ast/mod.rs
@@ -1672,6 +1672,10 @@ pub enum CTypeKind {
Half,
BFloat16,
+
+ // ARM Scalable Vector Extention types
+ // TODO: represent all the individual types in AArch64SVEACLETypes.def
+ UnhandledSveType,
}
impl CTypeKind {
diff --git a/c2rust-transpile/src/translator/mod.rs b/c2rust-transpile/src/translator/mod.rs
index 91144d0f29..99dca9734e 100644
--- a/c2rust-transpile/src/translator/mod.rs
+++ b/c2rust-transpile/src/translator/mod.rs
@@ -4921,6 +4921,9 @@ impl<'c> Translation<'c> {
// Handled in `import_simd_typedef`
}
TypeOfExpr(_) | BuiltinFn => {}
+ UnhandledSveType => {
+ // TODO: handle SVE types
+ }
}
}