mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 16:37:06 +00:00

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
125 lines
2.9 KiB
C++
125 lines
2.9 KiB
C++
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
|
|
|
|
#if __cplusplus >= 201103L
|
|
// expected-note@+3 2 {{candidate constructor}}
|
|
// expected-note@+2 {{passing argument to parameter here}}
|
|
#endif
|
|
struct A {
|
|
};
|
|
|
|
struct ConvertibleToA {
|
|
operator A();
|
|
};
|
|
|
|
struct ConvertibleToConstA {
|
|
#if __cplusplus >= 201103L
|
|
// expected-note@+2 {{candidate function}}
|
|
#endif
|
|
operator const A();
|
|
};
|
|
|
|
struct B {
|
|
B& operator=(B&); // expected-note 4 {{candidate function}}
|
|
};
|
|
|
|
struct ConvertibleToB {
|
|
operator B();
|
|
};
|
|
|
|
struct ConvertibleToBref {
|
|
operator B&();
|
|
};
|
|
|
|
struct ConvertibleToConstB {
|
|
operator const B();
|
|
};
|
|
|
|
struct ConvertibleToConstBref {
|
|
operator const B&();
|
|
};
|
|
|
|
struct C {
|
|
int operator=(int); // expected-note{{candidate function}}
|
|
long operator=(long); // expected-note{{candidate function}}
|
|
int operator+=(int); // expected-note{{candidate function}}
|
|
int operator+=(long); // expected-note{{candidate function}}
|
|
};
|
|
|
|
struct D {
|
|
D& operator+=(const D &);
|
|
};
|
|
|
|
struct ConvertibleToInt {
|
|
operator int();
|
|
};
|
|
|
|
void test() {
|
|
A a, na;
|
|
const A constA = A();
|
|
ConvertibleToA convertibleToA;
|
|
ConvertibleToConstA convertibleToConstA;
|
|
|
|
B b, nb;
|
|
const B constB = B();
|
|
ConvertibleToB convertibleToB;
|
|
ConvertibleToBref convertibleToBref;
|
|
ConvertibleToConstB convertibleToConstB;
|
|
ConvertibleToConstBref convertibleToConstBref;
|
|
|
|
C c, nc;
|
|
const C constC = C();
|
|
|
|
D d, nd;
|
|
const D constD = D();
|
|
|
|
ConvertibleToInt convertibleToInt;
|
|
|
|
na = a;
|
|
na = constA;
|
|
na = convertibleToA;
|
|
#if __cplusplus >= 201103L
|
|
// expected-error@+2 {{no viable conversion}}
|
|
#endif
|
|
na = convertibleToConstA;
|
|
na += a; // expected-error{{no viable overloaded '+='}}
|
|
|
|
nb = b;
|
|
nb = constB; // expected-error{{no viable overloaded '='}}
|
|
nb = convertibleToB; // expected-error{{no viable overloaded '='}}
|
|
nb = convertibleToBref;
|
|
nb = convertibleToConstB; // expected-error{{no viable overloaded '='}}
|
|
nb = convertibleToConstBref; // expected-error{{no viable overloaded '='}}
|
|
|
|
nc = c;
|
|
nc = constC;
|
|
nc = 1;
|
|
nc = 1L;
|
|
nc = 1.0; // expected-error{{use of overloaded operator '=' is ambiguous}}
|
|
nc += 1;
|
|
nc += 1L;
|
|
nc += 1.0; // expected-error{{use of overloaded operator '+=' is ambiguous}}
|
|
|
|
nd = d;
|
|
nd += d;
|
|
nd += constD;
|
|
|
|
int i;
|
|
i = convertibleToInt;
|
|
i = a; // expected-error{{assigning to 'int' from incompatible type 'A'}}
|
|
}
|
|
|
|
// Don't crash
|
|
namespace test1 {
|
|
template<typename T> class A : public unknown::X { // expected-error {{undeclared identifier 'unknown'}} expected-error {{expected class name}}
|
|
A(UndeclaredType n) : X(n) {} // expected-error {{unknown type name 'UndeclaredType'}}
|
|
// expected-error@-1 {{member initializer 'X' does not name a non-static data member or base class}}
|
|
};
|
|
template<typename T> class B : public A<T> {
|
|
virtual void foo() {}
|
|
};
|
|
extern template class A<char>;
|
|
extern template class B<char>;
|
|
}
|