llvm-capstone/clang/test/SemaCXX/arrow-operator.cpp
Aaron Ballman 0f1c1be196 [clang] Remove rdar links; NFC
We have a new policy in place making links to private resources
something we try to avoid in source and test files. Normally, we'd
organically switch to the new policy rather than make a sweeping change
across a project. However, Clang is in a somewhat special circumstance
currently: recently, I've had several new contributors run into rdar
links around test code which their patch was changing the behavior of.
This turns out to be a surprisingly bad experience, especially for
newer folks, for a handful of reasons: not understanding what the link
is and feeling intimidated by it, wondering whether their changes are
actually breaking something important to a downstream in some way,
having to hunt down strangers not involved with the patch to impose on
them for help, accidental pressure from asking for potentially private
IP to be made public, etc. Because folks run into these links entirely
by chance (through fixing bugs or working on new features), there's not
really a set of problematic links to focus on -- all of the links have
basically the same potential for causing these problems. As a result,
this is an omnibus patch to remove all such links.

This was not a mechanical change; it was done by manually searching for
rdar, radar, radr, and other variants to find all the various
problematic links. From there, I tried to retain or reword the
surrounding comments so that we would lose as little context as
possible. However, because most links were just a plain link with no
supporting context, the majority of the changes are simple removals.

Differential Review: https://reviews.llvm.org/D158071
2023-08-28 12:13:42 -04:00

118 lines
3.0 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -verify %s
struct T {
void f();
};
struct A {
T* operator->();
// expected-note@-1 {{member found by ambiguous name lookup}}
};
struct B {
T* operator->();
// expected-note@-1 {{member found by ambiguous name lookup}}
};
struct C : A, B {
};
struct D : A { };
struct E; // expected-note {{forward declaration of 'E'}}
void f(C &c, D& d, E& e) {
c->f();
// expected-error@-1 {{member 'operator->' found in multiple base classes of different types}}
d->f();
e->f(); // expected-error{{incomplete definition of type}}
}
namespace rdar8875304 {
class Point {};
class Line_Segment{ public: Line_Segment(const Point&){} };
class Node { public: Point Location(){ Point p; return p; } };
void f()
{
Node** node1;
Line_Segment(node1->Location()); // expected-error {{not a structure or union}}
}
}
namespace arrow_suggest {
template <typename T>
class wrapped_ptr {
public:
wrapped_ptr(T* ptr) : ptr_(ptr) {}
T* operator->() { return ptr_; }
void Check(); // expected-note {{'Check' declared here}}
private:
T *ptr_;
};
class Worker {
public:
void DoSomething(); // expected-note {{'DoSomething' declared here}}
void Chuck();
};
void test() {
wrapped_ptr<Worker> worker(new Worker);
worker.DoSomething(); // expected-error {{no member named 'DoSomething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}}
worker.DoSamething(); // expected-error {{no member named 'DoSamething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}} \
// expected-error {{no member named 'DoSamething' in 'arrow_suggest::Worker'; did you mean 'DoSomething'?}}
worker.Chuck(); // expected-error {{no member named 'Chuck' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean 'Check'?}}
}
} // namespace arrow_suggest
namespace no_crash_dependent_type {
template <class T>
struct A {
void call();
A *operator->();
};
template <class T>
void foo() {
// The "requires an initializer" error seems unnecessary.
A<int> &x = blah[7]; // expected-error {{use of undeclared identifier 'blah'}} \
// expected-error {{requires an initializer}}
// x is dependent.
x->call();
}
void test() {
foo<int>(); // expected-note {{requested here}}
}
} // namespace no_crash_dependent_type
namespace clangd_issue_1073_no_crash_dependent_type {
template <typename T> struct Ptr {
T *operator->();
};
struct Struct {
int len;
};
template <int>
struct TemplateStruct {
Ptr<Struct> val(); // expected-note {{declared here}}
};
template <int I>
void templateFunc(const TemplateStruct<I> &ts) {
Ptr<Struct> ptr = ts.val(); // expected-error {{function is not marked const}}
auto foo = ptr->len;
}
template void templateFunc<0>(const TemplateStruct<0> &); // expected-note {{requested here}}
} // namespace clangd_issue_1073_no_crash_dependent_type