llvm-capstone/clang/test/SemaTemplate/instantiate-declref.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

117 lines
2.7 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -verify %s
namespace N {
struct Outer {
struct Inner {
template<typename T>
struct InnerTemplate {
struct VeryInner {
typedef T type;
static enum K1 { K1Val = sizeof(T) } Kind1;
static enum { K2Val = sizeof(T)*2 } Kind2;
enum { K3Val = sizeof(T)*2 } Kind3;
void foo() {
K1 k1 = K1Val;
Kind1 = K1Val;
Outer::Inner::InnerTemplate<type>::VeryInner::Kind2 = K2Val;
Kind3 = K3Val;
}
struct UeberInner {
void bar() {
K1 k1 = K1Val;
Kind1 = K1Val;
Outer::Inner::InnerTemplate<type>::VeryInner::Kind2 = K2Val;
InnerTemplate t;
InnerTemplate<type> t2;
}
};
};
};
};
};
}
typedef int INT;
template struct N::Outer::Inner::InnerTemplate<INT>::VeryInner;
template struct N::Outer::Inner::InnerTemplate<INT>::UeberInner; // expected-error{{no struct named 'UeberInner' in 'N::Outer::Inner::InnerTemplate<int>'}}
namespace N2 {
struct Outer2 {
template<typename T, typename U = T>
struct Inner {
void foo() {
enum { K1Val = sizeof(T) } k1;
enum K2 { K2Val = sizeof(T)*2 } k2a;
K2 k2b = K2Val;
struct S { T x, y; } s1;
struct { U x, y; } s2;
s1.x = s2.x; // expected-error{{incompatible}}
typedef T type;
type t2 = s1.x;
typedef struct { T z; } type2;
type2 t3 = { s1.x };
Inner i1;
i1.foo();
Inner<T> i2;
i2.foo();
}
};
};
}
template struct N2::Outer2::Inner<float>;
template struct N2::Outer2::Inner<int*, float*>; // expected-note{{instantiation}}
// Test dependent pointer-to-member expressions.
template<typename T>
struct smart_ptr {
struct safe_bool {
int member;
};
operator int safe_bool::*() const {
return ptr? &safe_bool::member : 0;
}
T* ptr;
};
void test_smart_ptr(smart_ptr<int> p) {
if (p) { }
}
// PR5517
namespace test0 {
template <int K> struct X {
X() { extern void x(); }
};
void g() { X<2>(); }
}
namespace test1 {
template <typename T> void f(T const &t) {
union { char c; T t_; };
c = 'a'; // <- this shouldn't silently fail to instantiate
T::foo(); // expected-error {{has no members}}
}
template void f(int const &); // expected-note {{requested here}}
}
namespace test2 {
template<typename T> void f() {
T::error; // expected-error {{no member}}
}
void g() {
// This counts as an odr-use, so should trigger the instantiation of f<int>.
(void)&f<int>; // expected-note {{here}}
}
}