diff --git a/c2rust-ast-exporter/src/AstExporter.cpp b/c2rust-ast-exporter/src/AstExporter.cpp index e013bc6e4f..d5e9e7b68e 100644 --- a/c2rust-ast-exporter/src/AstExporter.cpp +++ b/c2rust-ast-exporter/src/AstExporter.cpp @@ -189,6 +189,24 @@ class TypeEncoder final : public TypeVisitor { astEncoder(ast) {} void VisitQualType(const QualType &QT) { + if(isa(QT)) { + // No printC11AtomicError available here and no location + // information either -- should better have been caught at the + // caller, but catching it here is still better than the + // nondescript error messages that would come later. + std::string msg = "C11 Atomics are not supported. No precise " + "location information available. Aborting."; + + auto &DiagEngine = Context->getDiagnostics(); + // Prefix warnings with `c2rust`, so the user can distinguish + // our warning messages from those generated by clang itself. + const auto ID = DiagEngine.getCustomDiagID(DiagnosticsEngine::Error, + "c2rust: %0"); + DiagEngine.Report(SourceLocation::getFromRawEncoding(0), ID).AddString(msg); + + abort(); + } + if (!QT.isNull()) { auto s = QT.split(); @@ -2188,6 +2206,17 @@ class TranslateASTVisitor final cbor_encode_boolean(array, D->isImplicit()); }); + if(isa(typeForDecl)) { + // This case is especially checked as that's what happens when + // clang's stdatomic.h is traversed. Other callers of VisitQualType + // could get the same check to preserve the location information + // available in Decl but not in Type, but those are more likely not + // to be hit, and can fall back to the less descriptive error from + // inside there. + printC11AtomicError(D); + abort(); + } + typeEncoder.VisitQualType(typeForDecl); return true;