Files
swift-mirror/test/Interop/Cxx/class/fixits-for-std-vector.swift
Doug Gregor 8cd2f34654 Generalize tests for both diagnostic styles, or force the LLVM style
These tests are using FileCheck to check the result of diagnostic
formatting in ways that don't match the new formatter. Force the old
formatter or, where possible, generalize so that they match both
formatters.
2024-02-19 02:48:37 -10:00

50 lines
1.4 KiB
Swift

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: not %target-swift-frontend -typecheck -I %t/Inputs %t/test.swift -enable-experimental-cxx-interop -diagnostic-style llvm 2>&1 | %FileCheck %s
// REQUIRES: OS=macosx || OS=linux-gnu
//--- Inputs/module.modulemap
module Test {
header "test.h"
requires cplusplus
}
//--- Inputs/test.h
#include <vector>
using V = std::vector<int>;
//--- test.swift
import Test
import CxxStdlib
public func test(v: V) {
// CHECK: note: C++ method 'begin' that returns an iterator is unavailable
// CHECK: note: do you want to use a for-in loop instead?
// CHECK: ^~~~~
// CHECK: makeIterator
_ = v.begin()
// CHECK: note: C++ method 'end' that returns an iterator is unavailable
// CHECK: note: do you want to compare against 'nil' instead?
// CHECK: ^~~~
// CHECK: nil
_ = v.end()
// CHECK: note: C++ method 'front' that returns a reference of type 'UnsafePointer' is unavailable
// CHECK: note: C++ method 'front' may return an interior pointer
// CHECK: note: do you want to get the first element instead?
// CHECK: ^~~~~~~
// CHECK: first
_ = v.front()
// CHECK: note: C++ method 'back' that returns a reference of type 'UnsafePointer' is unavailable
// CHECK: note: C++ method 'back' may return an interior pointer
// CHECK: note: do you want to get the last element instead?
// CHECK: ^~~~~~
// CHECK: last
_ = v.back()
}