Unnamed: 0
int64 0
0
| repo_id
stringlengths 5
186
| file_path
stringlengths 15
223
| content
stringlengths 1
32.8M
⌀ |
---|---|---|---|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/CodeCompletion/auto.cpp
|
// RUN: %clang_cc1 -std=c++11 -code-completion-at=%s:2:9 %s
auto i =
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/CodeCompletion/some_struct.h
|
struct X { int m; };
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/CodeCompletion/templates.cpp
|
namespace std {
template<typename T>
class allocator {
public:
void in_base();
};
template<typename T, typename Alloc = std::allocator<T> >
class vector : Alloc {
public:
void foo();
void stop();
};
template<typename Alloc> class vector<bool, Alloc>;
}
void f() {
std::vector<int> v;
v.foo();
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:18:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: allocator<<#typename T#>>
// CHECK-CC1-NEXT: vector<<#typename T#>{#, <#typename Alloc#>#}>
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:5 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
// CHECK-CC2: foo
// CHECK-CC2: in_base
// CHECK-CC2: stop
|
0 |
repos/DirectXShaderCompiler/tools/clang/test
|
repos/DirectXShaderCompiler/tools/clang/test/CodeCompletion/enum-switch-case.c
|
enum Color {
Red,
Orange,
Yellow,
Green,
Blue,
Indigo,
Violet
};
void test(enum Color color) {
switch (color) {
case Red:
break;
case Yellow:
break;
case Green:
break;
}
unsigned c2;
switch (c2) {
case
}
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:10 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: Blue
// CHECK-CC1-NEXT: Green
// CHECK-CC1-NEXT: Indigo
// CHECK-CC1-NEXT: Orange
// CHECK-CC1-NEXT: Violet
// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:25:10 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
// CHECK-CC2: COMPLETION: Blue : [#enum Color#]Blue
// CHECK-CC2-NEXT: COMPLETION: c2 : [#unsigned int#]c2
// CHECK-CC2-NEXT: COMPLETION: color : [#enum Color#]color
// CHECK-CC2-NEXT: COMPLETION: Green : [#enum Color#]Green
// CHECK-CC2-NEXT: COMPLETION: Indigo : [#enum Color#]Indigo
// CHECK-CC2-NEXT: COMPLETION: Orange : [#enum Color#]Orange
// CHECK-CC2-NEXT: COMPLETION: Red : [#enum Color#]Red
// CHECK-CC2-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
// CHECK-CC2-NEXT: COMPLETION: Violet : [#enum Color#]Violet
// CHECK-CC2-NEXT: COMPLETION: Yellow : [#enum Color#]Yellow
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CodeCompletion
|
repos/DirectXShaderCompiler/tools/clang/test/CodeCompletion/Inputs/macros.h
|
#define FOO
#define BAR(X, Y) X, Y
#define IDENTITY(X) X
#define WIBBLE(...)
#define DEAD_MACRO
#undef DEAD_MACRO
#define MACRO_WITH_HISTORY a
#undef MACRO_WITH_HISTORY
#define MACRO_WITH_HISTORY b, c
#undef MACRO_WITH_HISTORY
#define MACRO_WITH_HISTORY(X, Y) X->Y
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CodeCompletion
|
repos/DirectXShaderCompiler/tools/clang/test/CodeCompletion/Inputs/reserved.h
|
typedef int _INTEGER_TYPE;
typedef float FLOATING_TYPE;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr19xx.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
namespace std { struct type_info; }
namespace dr1902 { // dr1902: 3.7
struct A {};
struct B {
B(A);
#if __cplusplus >= 201103L
// expected-note@-2 {{candidate}}
#endif
B() = delete;
#if __cplusplus < 201103L
// expected-error@-2 {{extension}}
#endif
B(const B&) // expected-note {{deleted here}}
#if __cplusplus >= 201103L
// expected-note@-2 {{candidate}}
#else
// expected-error@+2 {{extension}}
#endif
= delete;
operator A();
};
extern B b1;
B b2(b1); // expected-error {{call to deleted}}
#if __cplusplus >= 201103L
// This is ambiguous, even though calling the B(const B&) constructor would
// both directly and indirectly call a deleted function.
B b({}); // expected-error {{ambiguous}}
#endif
}
namespace dr1909 { // dr1909: yes
struct A {
template<typename T> struct A {}; // expected-error {{member 'A' has the same name as its class}}
};
struct B {
template<typename T> void B() {} // expected-error {{constructor cannot have a return type}}
};
struct C {
template<typename T> static int C; // expected-error {{member 'C' has the same name as its class}} expected-error 0-1{{extension}}
};
struct D {
template<typename T> using D = int; // expected-error {{member 'D' has the same name as its class}} expected-error 0-1{{extension}}
};
}
#if __cplusplus >= 201103L
namespace dr1940 { // dr1940: yes
static union {
static_assert(true, ""); // ok
static_assert(false, ""); // expected-error {{static_assert failed}}
};
}
#endif
#if __cplusplus >= 201402L
namespace dr1947 { // dr1947: yes
unsigned o = 0'01; // ok
unsigned b = 0b'01; // expected-error {{invalid digit 'b' in octal constant}}
unsigned x = 0x'01; // expected-error {{invalid suffix 'x'01' on integer constant}}
}
#endif
#if __cplusplus >= 201103L
// dr1948: yes
// FIXME: This diagnostic could be improved.
void *operator new(__SIZE_TYPE__) noexcept { return nullptr; } // expected-error{{exception specification in declaration does not match previous declaration}}
#endif
#if __cplusplus >= 201103L
namespace dr1968 { // dr1968: yes
static_assert(&typeid(int) == &typeid(int), ""); // expected-error{{not an integral constant expression}}
}
#endif
// dr1994: dup 529
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr17xx.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// expected-no-diagnostics
#if __cplusplus >= 201103L
namespace dr1756 { // dr1756: 3.7 c++11
// Direct-list-initialization of a non-class object
int a{0};
struct X { operator int(); } x;
int b{x};
} // dr1756
namespace dr1758 { // dr1758: 3.7 c++11
// Explicit conversion in copy/move list initialization
struct X { X(); };
struct Y { explicit operator X(); } y;
X x{y};
struct A {
A() {}
A(const A &) {}
};
struct B {
operator A() { return A(); }
} b;
A a{b};
} // dr1758
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr3xx.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
namespace dr300 { // dr300: yes
template<typename R, typename A> void f(R (&)(A)) {}
int g(int);
void h() { f(g); }
}
namespace dr301 { // dr301: yes
// see also dr38
struct S;
template<typename T> void operator+(T, T);
void operator-(S, S);
void f() {
bool a = (void(*)(S, S))operator+<S> <
(void(*)(S, S))operator+<S>;
bool b = (void(*)(S, S))operator- <
(void(*)(S, S))operator-;
bool c = (void(*)(S, S))operator+ <
(void(*)(S, S))operator-; // expected-error {{expected '>'}}
}
template<typename T> void f() {
typename T::template operator+<int> a; // expected-error {{typename specifier refers to a non-type template}} expected-error +{{}}
// FIXME: This shouldn't say (null).
class T::template operator+<int> b; // expected-error {{identifier followed by '<' indicates a class template specialization but (null) refers to a function template}}
enum T::template operator+<int> c; // expected-error {{expected identifier}} expected-error {{does not declare anything}}
enum T::template operator+<int>::E d; // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}} expected-error {{forward reference}}
enum T::template X<int>::E e;
T::template operator+<int>::foobar(); // expected-error {{qualified name refers into a specialization of function template 'T::template operator +'}}
T::template operator+<int>(0); // ok
}
template<typename T> class operator&<T*> {}; // expected-error +{{}}
template<typename T> class T::operator& {}; // expected-error +{{}}
template<typename T> class S::operator&<T*> {}; // expected-error +{{}}
}
namespace dr302 { // dr302: yes
struct A { A(); ~A(); };
#if __cplusplus < 201103L
struct B { // expected-error {{implicit default constructor for 'dr302::B' must explicitly initialize the const member 'n'}}
const int n; // expected-note {{declared here}}
A a;
} b = B(); // expected-note {{first required here}}
// Trivial default constructor C::C() is not called here.
struct C {
const int n;
} c = C();
#else
struct B {
const int n; // expected-note {{deleted because field 'n' of const-qualified type 'const int' would not be initialized}}
A a;
} b = B(); // expected-error {{call to implicitly-deleted default constructor}}
// C::C() is called here, because even though it's trivial, it's deleted.
struct C {
const int n; // expected-note {{deleted because field 'n' of const-qualified type 'const int' would not be initialized}}
} c = C(); // expected-error {{call to implicitly-deleted default constructor}}
struct D {
const int n = 0;
} d = D();
#endif
}
// dr303: na
namespace dr304 { // dr304: yes
typedef int &a;
int n = a(); // expected-error {{requires an initializer}}
struct S { int &b; };
int m = S().b;
#if __cplusplus < 201103L
// expected-error@-3 {{requires an initializer}}
// expected-note@-3 {{in value-initialization}}
#else
// expected-error@-5 {{deleted}}
// expected-note@-7 {{reference}}
#endif
}
namespace dr305 { // dr305: no
struct A {
typedef A C;
};
void f(A *a) {
struct A {};
a->~A();
a->~C();
}
typedef A B;
void g(B *b) {
b->~B();
b->~C();
}
void h(B *b) {
struct B {}; // expected-note {{declared here}}
b->~B(); // expected-error {{does not match}}
}
template<typename T> struct X {};
void i(X<int>* x) {
struct X {};
x->~X<int>();
x->~X();
x->~X<char>(); // expected-error {{no member named}}
}
#if __cplusplus >= 201103L
struct Y {
template<typename T> using T1 = Y;
};
template<typename T> using T2 = Y;
void j(Y *y) {
y->~T1<int>();
y->~T2<int>();
}
struct Z {
template<typename T> using T2 = T;
};
void k(Z *z) {
// FIXME: This diagnostic is terrible.
z->~T1<int>(); // expected-error {{'T1' following the 'template' keyword does not refer to a template}} expected-error +{{}}
z->~T2<int>(); // expected-error {{no member named '~int'}}
z->~T2<Z>();
}
// FIXME: This is valid.
namespace Q {
template<typename A> struct R {};
}
template<typename A> using R = Q::R<int>;
void qr(Q::R<int> x) { x.~R<char>(); } // expected-error {{no member named}}
#endif
}
namespace dr306 { // dr306: no
// FIXME: dup 39
// FIXME: This should be accepted.
struct A { struct B {}; }; // expected-note 2{{member}}
struct C { typedef A::B B; }; // expected-note {{member}}
struct D : A, A::B, C {};
D::B b; // expected-error {{found in multiple base classes of different types}}
}
// dr307: na
namespace dr308 { // dr308: yes
// This is mostly an ABI library issue.
struct A {};
struct B : A {};
struct C : A {};
struct D : B, C {};
void f() {
try {
throw D();
} catch (const A&) { // expected-note {{for type 'const dr308::A &'}}
// unreachable
} catch (const B&) { // expected-warning {{exception of type 'const dr308::B &' will be caught by earlier handler}}
// get here instead
}
}
}
// dr309: dup 485
namespace dr311 { // dr311: yes
namespace X { namespace Y {} }
namespace X::Y {}
#if __cplusplus <= 201402L
// expected-error@-2 {{define each namespace separately}}
#endif
namespace X {
namespace X::Y {}
#if __cplusplus <= 201402L
// expected-error@-2 {{define each namespace separately}}
#endif
}
// FIXME: The diagnostics here are not very good.
namespace ::dr311::X {} // expected-error 2+{{}} // expected-warning {{extra qual}}
}
// dr312: dup 616
namespace dr313 { // dr313: dup 299 c++11
struct A { operator int() const; };
int *p = new int[A()];
#if __cplusplus < 201103L
// FIXME: should this be available in c++98 mode? expected-error@-2 {{extension}}
#endif
}
namespace dr314 { // FIXME 314: dup 1710
template<typename T> struct A {
template<typename U> struct B {};
};
template<typename T> struct C : public A<T>::template B<T> {
C() : A<T>::template B<T>() {}
};
}
// dr315: na
// dr316: sup 1004
namespace dr317 { // dr317: 3.5
void f() {} // expected-note {{previous}}
inline void f(); // expected-error {{inline declaration of 'f' follows non-inline definition}}
int g();
int n = g();
inline int g() { return 0; }
int h();
int m = h();
int h() { return 0; } // expected-note {{previous}}
inline int h(); // expected-error {{inline declaration of 'h' follows non-inline definition}}
}
namespace dr318 { // dr318: sup 1310
struct A {};
struct A::A a;
}
namespace dr319 { // dr319: no
// FIXME: dup dr389
// FIXME: We don't have a diagnostic for a name with linkage
// having a type without linkage.
typedef struct {
int i;
} *ps;
extern "C" void f(ps);
void g(ps); // FIXME: ill-formed, type 'ps' has no linkage
static enum { e } a1;
enum { e2 } a2; // FIXME: ill-formed, enum type has no linkage
enum { n1 = 1u };
typedef int (*pa)[n1];
pa parr; // ok, type has linkage despite using 'n1'
template<typename> struct X {};
void f() {
struct A { int n; };
extern A a; // FIXME: ill-formed
X<A> xa;
typedef A B;
extern B b; // FIXME: ill-formed
X<B> xb;
const int n = 1;
typedef int (*C)[n];
extern C c; // ok
X<C> xc;
}
#if __cplusplus < 201103L
// expected-error@-12 {{uses local type 'A'}}
// expected-error@-9 {{uses local type 'A'}}
#endif
}
namespace dr320 { // dr320: yes
#if __cplusplus >= 201103L
struct X {
constexpr X() {}
constexpr X(const X &x) : copies(x.copies + 1) {}
unsigned copies = 0;
};
constexpr X f(X x) { return x; }
constexpr unsigned g(X x) { return x.copies; }
static_assert(f(X()).copies == g(X()) + 1, "expected one extra copy for return value");
#endif
}
namespace dr321 { // dr321: dup 557
namespace N {
template<int> struct A {
template<int> struct B;
};
template<> template<> struct A<0>::B<0>;
void f(A<0>::B<0>);
}
template<> template<> struct N::A<0>::B<0> {};
template<typename T> void g(T t) { f(t); }
template void g(N::A<0>::B<0>);
namespace N {
template<typename> struct I { friend bool operator==(const I&, const I&); };
}
N::I<int> i, j;
bool x = i == j;
}
namespace dr322 { // dr322: yes
struct A {
template<typename T> operator T&();
} a;
int &r = static_cast<int&>(a);
int &s = a;
}
// dr323: no
namespace dr324 { // dr324: yes
struct S { int n : 1; } s; // expected-note 3{{bit-field is declared here}}
int &a = s.n; // expected-error {{non-const reference cannot bind to bit-field}}
int *b = &s.n; // expected-error {{address of bit-field}}
int &c = (s.n = 0); // expected-error {{non-const reference cannot bind to bit-field}}
int *d = &(s.n = 0); // expected-error {{address of bit-field}}
int &e = true ? s.n : s.n; // expected-error {{non-const reference cannot bind to bit-field}}
int *f = &(true ? s.n : s.n); // expected-error {{address of bit-field}}
int &g = (void(), s.n); // expected-error {{non-const reference cannot bind to bit-field}}
int *h = &(void(), s.n); // expected-error {{address of bit-field}}
int *i = &++s.n; // expected-error {{address of bit-field}}
}
namespace dr326 { // dr326: yes
struct S {};
int test[__is_trivially_constructible(S, const S&) ? 1 : -1];
}
namespace dr327 { // dr327: dup 538
struct A;
class A {};
class B;
struct B {};
}
namespace dr328 { // dr328: yes
struct A; // expected-note 3{{forward declaration}}
struct B { A a; }; // expected-error {{incomplete}}
template<typename> struct C { A a; }; // expected-error {{incomplete}}
A *p = new A[0]; // expected-error {{incomplete}}
}
namespace dr329 { // dr329: 3.5
struct B {};
template<typename T> struct A : B {
friend void f(A a) { g(a); }
friend void h(A a) { g(a); } // expected-error {{undeclared}}
friend void i(B b) {} // expected-error {{redefinition}} expected-note {{previous}}
};
A<int> a;
A<char> b; // expected-note {{instantiation}}
void test() {
h(a); // expected-note {{instantiation}}
}
}
namespace dr331 { // dr331: yes
struct A {
A(volatile A&); // expected-note {{candidate}}
} const a, b(a); // expected-error {{no matching constructor}}
}
namespace dr332 { // dr332: dup 577
void f(volatile void); // expected-error {{'void' as parameter must not have type qualifiers}}
void g(const void); // expected-error {{'void' as parameter must not have type qualifiers}}
void h(int n, volatile void); // expected-error {{'void' must be the first and only parameter}}
}
namespace dr333 { // dr333: yes
int n = 0;
int f(int(n));
int g((int(n)));
int h = f(g);
}
namespace dr334 { // dr334: yes
template<typename T> void f() {
T x;
f((x, 123));
}
struct S {
friend S operator,(S, int);
friend void f(S);
};
template void f<S>();
}
// dr335: no
namespace dr336 { // dr336: yes
namespace Pre {
template<class T1> class A {
template<class T2> class B {
template<class T3> void mf1(T3);
void mf2();
};
};
template<> template<class X> class A<int>::B {};
template<> template<> template<class T> void A<int>::B<double>::mf1(T t) {} // expected-error {{does not match}}
template<class Y> template<> void A<Y>::B<double>::mf2() {} // expected-error {{does not refer into a class}}
}
namespace Post {
template<class T1> class A {
template<class T2> class B {
template<class T3> void mf1(T3);
void mf2();
};
};
template<> template<class X> class A<int>::B {
template<class T> void mf1(T);
};
template<> template<> template<class T> void A<int>::B<double>::mf1(T t) {}
// FIXME: This diagnostic isn't very good.
template<class Y> template<> void A<Y>::B<double>::mf2() {} // expected-error {{does not refer into a class}}
}
}
namespace dr337 { // dr337: yes
template<typename T> void f(T (*)[1]);
template<typename T> int &f(...);
struct A { virtual ~A() = 0; };
int &r = f<A>(0);
// FIXME: The language rules here are completely broken. We cannot determine
// whether an incomplete type is abstract. See DR1640, which will probably
// supersede this one and remove this rule.
struct B;
int &s = f<B>(0); // expected-error {{of type 'void'}}
struct B { virtual ~B() = 0; };
}
namespace dr339 { // dr339: yes
template <int I> struct A { static const int value = I; };
char xxx(int);
char (&xxx(float))[2];
template<class T> A<sizeof(xxx((T)0))> f(T) {} // expected-note {{candidate}}
void test() {
A<1> a = f(0);
A<2> b = f(0.0f);
A<3> c = f("foo"); // expected-error {{no matching function}}
}
char f(int);
int f(...);
template <class T> struct conv_int {
static const bool value = sizeof(f(T())) == 1;
};
template <class T> bool conv_int2(A<sizeof(f(T()))> p);
template<typename T> A<sizeof(f(T()))> make_A();
int a[conv_int<char>::value ? 1 : -1];
bool b = conv_int2<char>(A<1>());
A<1> c = make_A<char>();
}
namespace dr340 { // dr340: yes
struct A { A(int); };
struct B { B(A, A, int); };
int x, y;
B b(A(x), A(y), 3);
}
namespace dr341 { // dr341: sup 1708
namespace A {
int n;
extern "C" int &dr341_a = n; // expected-note {{previous}} expected-note {{declared with C language linkage here}}
}
namespace B {
extern "C" int &dr341_a = dr341_a; // expected-error {{redefinition}}
}
extern "C" void dr341_b(); // expected-note {{declared with C language linkage here}}
}
int dr341_a; // expected-error {{declaration of 'dr341_a' in global scope conflicts with declaration with C language linkage}}
int dr341_b; // expected-error {{declaration of 'dr341_b' in global scope conflicts with declaration with C language linkage}}
int dr341_c; // expected-note {{declared in global scope here}}
int dr341_d; // expected-note {{declared in global scope here}}
namespace dr341 {
extern "C" int dr341_c; // expected-error {{declaration of 'dr341_c' with C language linkage conflicts with declaration in global scope}}
extern "C" void dr341_d(); // expected-error {{declaration of 'dr341_d' with C language linkage conflicts with declaration in global scope}}
namespace A { extern "C" int dr341_e; } // expected-note {{previous}}
namespace B { extern "C" void dr341_e(); } // expected-error {{redefinition of 'dr341_e' as different kind of symbol}}
}
// dr342: na
namespace dr343 { // FIXME 343: no
// FIXME: dup 1710
template<typename T> struct A {
template<typename U> struct B {};
};
// FIXME: In these contexts, the 'template' keyword is optional.
template<typename T> struct C : public A<T>::B<T> { // expected-error {{use 'template'}}
C() : A<T>::B<T>() {} // expected-error {{use 'template'}}
};
}
namespace dr344 { // dr344: dup 1435
struct A { inline virtual ~A(); };
struct B { friend A::~A(); };
}
namespace dr345 { // dr345: yes
struct A {
struct X {};
int X; // expected-note {{here}}
};
struct B {
struct X {};
};
template <class T> void f(T t) { typename T::X x; } // expected-error {{refers to non-type member 'X'}}
void f(A a, B b) {
f(b);
f(a); // expected-note {{instantiation}}
}
}
// dr346: na
namespace dr347 { // dr347: yes
struct base {
struct nested;
static int n;
static void f();
void g();
};
struct derived : base {};
struct derived::nested {}; // expected-error {{no struct named 'nested'}}
int derived::n; // expected-error {{no member named 'n'}}
void derived::f() {} // expected-error {{does not match any}}
void derived::g() {} // expected-error {{does not match any}}
}
// dr348: na
namespace dr349 { // dr349: no
struct A {
template <class T> operator T ***() {
int ***p = 0;
return p; // expected-error {{cannot initialize return object of type 'const int ***' with an lvalue of type 'int ***'}}
}
};
// FIXME: This is valid.
A a;
const int *const *const *p1 = a; // expected-note {{in instantiation of}}
struct B {
template <class T> operator T ***() {
const int ***p = 0;
return p;
}
};
// FIXME: This is invalid.
B b;
const int *const *const *p2 = b;
}
// dr351: na
namespace dr352 { // dr352: yes
namespace example1 {
namespace A {
enum E {};
template<typename R, typename A> void foo(E, R (*)(A)); // expected-note 2{{couldn't infer template argument 'R'}}
}
template<typename T> void arg(T);
template<typename T> int arg(T) = delete; // expected-note {{here}} expected-error 0-1{{extension}}
void f(A::E e) {
foo(e, &arg); // expected-error {{no matching function}}
using A::foo;
foo<int, int>(e, &arg); // expected-error {{deleted}}
}
int arg(int);
void g(A::E e) {
foo(e, &arg); // expected-error {{no matching function}}
using A::foo;
foo<int, int>(e, &arg); // ok, uses non-template
}
}
namespace contexts {
template<int I> void f1(int (&)[I]);
template<int I> void f2(int (&)[I+1]); // expected-note {{couldn't infer}}
template<int I> void f3(int (&)[I+1], int (&)[I]);
void f() {
int a[4];
int b[3];
f1(a);
f2(a); // expected-error {{no matching function}}
f3(a, b);
}
template<int I> struct S {};
template<int I> void g1(S<I>);
template<int I> void g2(S<I+1>); // expected-note {{couldn't infer}}
template<int I> void g3(S<I+1>, S<I>);
void g() {
S<4> a;
S<3> b;
g1(a);
g2(a); // expected-error {{no matching function}}
g3(a, b);
}
template<typename T> void h1(T = 0); // expected-note {{couldn't infer}}
template<typename T> void h2(T, T = 0);
void h() {
h1(); // expected-error {{no matching function}}
h1(0);
h1<int>();
h2(0);
}
template<typename T> int tmpl(T);
template<typename R, typename A> void i1(R (*)(A)); // expected-note 3{{couldn't infer}}
template<typename R, typename A> void i2(R, A, R (*)(A)); // expected-note {{not viable}}
void i() {
extern int single(int);
i1(single);
i2(0, 0, single);
extern int ambig(float), ambig(int);
i1(ambig); // expected-error {{no matching function}}
i2(0, 0, ambig);
extern void no_match(float), no_match(int);
i1(no_match); // expected-error {{no matching function}}
i2(0, 0, no_match); // expected-error {{no matching function}}
i1(tmpl); // expected-error {{no matching function}}
i2(0, 0, tmpl);
}
}
template<typename T> struct is_int;
template<> struct is_int<int> {};
namespace example2 {
template<typename T> int f(T (*p)(T)) { is_int<T>(); }
int g(int);
int g(char);
int i = f(g);
}
namespace example3 {
template<typename T> int f(T, T (*p)(T)) { is_int<T>(); }
int g(int);
char g(char);
int i = f(1, g);
}
namespace example4 {
template <class T> int f(T, T (*p)(T)) { is_int<T>(); }
char g(char);
template <class T> T g(T);
int i = f(1, g);
}
namespace example5 {
template<int I> class A {};
template<int I> void g(A<I+1>); // expected-note {{couldn't infer}}
template<int I> void f(A<I>, A<I+1>);
void h(A<1> a1, A<2> a2) {
g(a1); // expected-error {{no matching function}}
g<0>(a1);
f(a1, a2);
}
}
}
// dr353 needs an IRGen test.
namespace dr354 { // dr354: yes c++11
// FIXME: Should we allow this in C++98 too?
struct S {};
template<int*> struct ptr {}; // expected-note 0-4{{here}}
ptr<0> p0;
ptr<(int*)0> p1;
ptr<(float*)0> p2;
ptr<(int S::*)0> p3;
#if __cplusplus < 201103L
// expected-error@-5 {{does not refer to any decl}}
// expected-error@-5 {{does not refer to any decl}}
// expected-error@-5 {{does not refer to any decl}}
// expected-error@-5 {{does not refer to any decl}}
#elif __cplusplus <= 201402L
// expected-error@-10 {{must be cast}}
// ok
// expected-error@-10 {{does not match}}
// expected-error@-10 {{does not match}}
#else
// expected-error@-15 {{conversion from 'int' to 'int *' is not allowed}}
// ok
// expected-error@-15 {{'float *' is not implicitly convertible to 'int *'}}
// expected-error@-15 {{'int dr354::S::*' is not implicitly convertible to 'int *'}}
#endif
template<int*> int both();
template<int> int both();
int b0 = both<0>();
int b1 = both<(int*)0>();
#if __cplusplus < 201103L
// expected-error@-2 {{no matching function}}
// expected-note@-6 {{candidate}}
// expected-note@-6 {{candidate}}
#endif
template<int S::*> struct ptr_mem {}; // expected-note 0-4{{here}}
ptr_mem<0> m0;
ptr_mem<(int S::*)0> m1;
ptr_mem<(float S::*)0> m2;
ptr_mem<(int *)0> m3;
#if __cplusplus < 201103L
// expected-error@-5 {{cannot be converted}}
// expected-error@-5 {{is not a pointer to member constant}}
// expected-error@-5 {{cannot be converted}}
// expected-error@-5 {{cannot be converted}}
#elif __cplusplus <= 201402L
// expected-error@-10 {{must be cast}}
// ok
// expected-error@-10 {{does not match}}
// expected-error@-10 {{does not match}}
#else
// expected-error@-15 {{conversion from 'int' to 'int dr354::S::*' is not allowed}}
// ok
// expected-error@-15 {{'float dr354::S::*' is not implicitly convertible to 'int dr354::S::*'}}
// expected-error@-15 {{'int *' is not implicitly convertible to 'int dr354::S::*'}}
#endif
}
struct dr355_S; // dr355: yes
struct ::dr355_S {}; // expected-warning {{extra qualification}}
namespace dr355 { struct ::dr355_S s; }
// dr356: na
namespace dr357 { // dr357: yes
template<typename T> struct A {
void f() const; // expected-note {{const qualified}}
};
template<typename T> void A<T>::f() {} // expected-error {{does not match}}
struct B {
template<typename T> void f();
};
template<typename T> void B::f() const {} // expected-error {{does not match}}
}
namespace dr358 { // dr358: yes
extern "C" void dr358_f();
namespace N {
int var;
extern "C" void dr358_f() { var = 10; }
}
}
namespace dr359 { // dr359: yes
// Note, the example in the DR is wrong; it doesn't contain an anonymous
// union.
struct E {
union {
struct {
int x;
} s;
} v;
union {
struct { // expected-error {{extension}}
int x;
} s;
struct S { // expected-error {{types cannot be declared in an anonymous union}}
int x;
} t;
union { // expected-error {{extension}}
int u;
};
};
};
}
// dr362: na
// dr363: na
namespace dr364 { // dr364: yes
struct S {
static void f(int);
void f(char);
};
void g() {
S::f('a'); // expected-error {{call to non-static}}
S::f(0);
}
}
#if "foo" // expected-error {{invalid token}} dr366: yes
#endif
namespace dr367 { // dr367: yes
// FIXME: These diagnostics are terrible. Don't diagnose an ill-formed global
// array as being a VLA!
int a[true ? throw 0 : 4]; // expected-error 2{{variable length array}}
int b[true ? 4 : throw 0];
int c[true ? *new int : 4]; // expected-error 2{{variable length array}}
int d[true ? 4 : *new int];
#if __cplusplus < 201103L
// expected-error@-4 {{variable length array}} expected-error@-4 {{constant expression}}
// expected-error@-3 {{variable length array}} expected-error@-3 {{constant expression}}
#endif
}
namespace dr368 { // dr368: yes
template<typename T, T> struct S {}; // expected-note {{here}}
template<typename T> int f(S<T, T()> *); // expected-error {{function type}}
//template<typename T> int g(S<T, (T())> *); // FIXME: crashes clang
template<typename T> int g(S<T, true ? T() : T()> *); // expected-note {{cannot have type 'dr368::X'}}
struct X {};
int n = g<X>(0); // expected-error {{no matching}}
}
// dr370: na
namespace dr372 { // dr372: no
namespace example1 {
template<typename T> struct X {
protected:
typedef T Type; // expected-note 2{{protected}}
};
template<typename T> struct Y {};
// FIXME: These two are valid; deriving from T1<T> gives Z1 access to
// the protected member T1<T>::Type.
template<typename T,
template<typename> class T1,
template<typename> class T2> struct Z1 :
T1<T>,
T2<typename T1<T>::Type> {}; // expected-error {{protected}}
template<typename T,
template<typename> class T1,
template<typename> class T2> struct Z2 :
T2<typename T1<T>::Type>, // expected-error {{protected}}
T1<T> {};
Z1<int, X, Y> z1; // expected-note {{instantiation of}}
Z2<int, X, Y> z2; // expected-note {{instantiation of}}
}
namespace example2 {
struct X {
private:
typedef int Type; // expected-note {{private}}
};
template<typename T> struct A {
typename T::Type t; // expected-error {{private}}
};
A<X> ax; // expected-note {{instantiation of}}
}
namespace example3 {
struct A {
protected:
typedef int N; // expected-note 2{{protected}}
};
template<typename T> struct B {};
template<typename U> struct C : U, B<typename U::N> {}; // expected-error {{protected}}
template<typename U> struct D : B<typename U::N>, U {}; // expected-error {{protected}}
C<A> x; // expected-note {{instantiation of}}
D<A> y; // expected-note {{instantiation of}}
}
namespace example4 {
class A {
class B {};
friend class X;
};
struct X : A::B {
A::B mx;
class Y {
A::B my;
};
};
}
}
namespace dr373 { // dr373: no
// FIXME: This is valid.
namespace X { int dr373; } // expected-note 2{{here}}
struct dr373 { // expected-note {{here}}
void f() {
using namespace dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}}
int k = dr373; // expected-error {{does not refer to a value}}
namespace Y = dr373::X; // expected-error {{no namespace named 'X' in 'dr373::dr373'}}
k = Y::dr373;
}
};
}
namespace dr374 { // dr374: yes c++11
namespace N {
template<typename T> void f();
template<typename T> struct A { void f(); };
}
template<> void N::f<char>() {}
template<> void N::A<char>::f() {}
template<> struct N::A<int> {};
#if __cplusplus < 201103L
// expected-error@-4 {{extension}} expected-note@-7 {{here}}
// expected-error@-4 {{extension}} expected-note@-7 {{here}}
// expected-error@-4 {{extension}} expected-note@-8 {{here}}
#endif
}
// dr375: dup 345
// dr376: na
namespace dr377 { // dr377: yes
enum E { // expected-error {{enumeration values exceed range of largest integer}}
a = -__LONG_LONG_MAX__ - 1, // expected-error 0-1{{extension}}
b = 2 * (unsigned long long)__LONG_LONG_MAX__ // expected-error 0-2{{extension}}
};
}
// dr378: dup 276
// dr379: na
namespace dr381 { // dr381: yes
struct A {
int a;
};
struct B : virtual A {};
struct C : B {};
struct D : B {};
struct E : public C, public D {};
struct F : public A {};
void f() {
E e;
e.B::a = 0; // expected-error {{ambiguous conversion}}
F f;
f.A::a = 1;
}
}
namespace dr382 { // dr382: yes c++11
// FIXME: Should we allow this in C++98 mode?
struct A { typedef int T; };
typename A::T t;
typename dr382::A a;
#if __cplusplus < 201103L
// expected-error@-3 {{occurs outside of a template}}
// expected-error@-3 {{occurs outside of a template}}
#endif
typename A b; // expected-error {{expected a qualified name}}
}
namespace dr383 { // dr383: yes
struct A { A &operator=(const A&); };
struct B { ~B(); };
union C { C &operator=(const C&); };
union D { ~D(); };
int check[(__is_pod(A) || __is_pod(B) || __is_pod(C) || __is_pod(D)) ? -1 : 1];
}
namespace dr384 { // dr384: yes
namespace N1 {
template<typename T> struct Base {};
template<typename T> struct X {
struct Y : public Base<T> {
Y operator+(int) const;
};
Y f(unsigned i) { return Y() + i; }
};
}
namespace N2 {
struct Z {};
template<typename T> int *operator+(T, unsigned);
}
int main() {
N1::X<N2::Z> v;
v.f(0);
}
}
namespace dr385 { // dr385: yes
struct A { protected: void f(); };
struct B : A { using A::f; };
struct C : A { void g(B b) { b.f(); } };
void h(B b) { b.f(); }
struct D { int n; }; // expected-note {{member}}
struct E : protected D {}; // expected-note 2{{protected}}
struct F : E { friend int i(E); };
int i(E e) { return e.n; } // expected-error {{protected base}} expected-error {{protected member}}
}
namespace dr387 { // dr387: yes
namespace old {
template<typename T> class number {
number(int); // expected-note 2{{here}}
friend number gcd(number &x, number &y) {}
};
void g() {
number<double> a(3), b(4); // expected-error 2{{private}}
a = gcd(a, b);
b = gcd(3, 4); // expected-error {{undeclared}}
}
}
namespace newer {
template <typename T> class number {
public:
number(int);
friend number gcd(number x, number y) { return 0; }
};
void g() {
number<double> a(3), b(4);
a = gcd(a, b);
b = gcd(3, 4); // expected-error {{undeclared}}
}
}
}
// FIXME: dr388 needs codegen test
namespace dr389 { // dr389: no
struct S {
typedef struct {} A;
typedef enum {} B;
typedef struct {} const C; // expected-note 0-2{{here}}
typedef enum {} const D; // expected-note 0-1{{here}}
};
template<typename> struct T {};
struct WithLinkage1 {};
enum WithLinkage2 {};
typedef struct {} *WithLinkage3a, WithLinkage3b;
typedef enum {} WithLinkage4a, *WithLinkage4b;
typedef S::A WithLinkage5;
typedef const S::B WithLinkage6;
typedef int WithLinkage7;
typedef void (*WithLinkage8)(WithLinkage2 WithLinkage1::*, WithLinkage5 *);
typedef T<WithLinkage5> WithLinkage9;
typedef struct {} *WithoutLinkage1; // expected-note 0-1{{here}}
typedef enum {} const WithoutLinkage2; // expected-note 0-1{{here}}
// These two types don't have linkage even though they are externally visible
// and the ODR requires them to be merged across TUs.
typedef S::C WithoutLinkage3;
typedef S::D WithoutLinkage4;
typedef void (*WithoutLinkage5)(int (WithoutLinkage3::*)(char));
#if __cplusplus >= 201103L
// This has linkage even though its template argument does not.
// FIXME: This is probably a defect.
typedef T<WithoutLinkage1> WithLinkage10;
#else
typedef int WithLinkage10; // dummy
typedef T<WithLinkage1> GoodArg1;
typedef T<WithLinkage2> GoodArg2;
typedef T<WithLinkage3a> GoodArg3a;
typedef T<WithLinkage3b> GoodArg3b;
typedef T<WithLinkage4a> GoodArg4a;
typedef T<WithLinkage4b> GoodArg4b;
typedef T<WithLinkage5> GoodArg5;
typedef T<WithLinkage6> GoodArg6;
typedef T<WithLinkage7> GoodArg7;
typedef T<WithLinkage8> GoodArg8;
typedef T<WithLinkage9> GoodArg9;
typedef T<WithoutLinkage1> BadArg1; // expected-error{{template argument uses}}
typedef T<WithoutLinkage2> BadArg2; // expected-error{{template argument uses}}
typedef T<WithoutLinkage3> BadArg3; // expected-error{{template argument uses}}
typedef T<WithoutLinkage4> BadArg4; // expected-error{{template argument uses}}
typedef T<WithoutLinkage5> BadArg5; // expected-error{{template argument uses}}
#endif
extern WithLinkage1 withLinkage1;
extern WithLinkage2 withLinkage2;
extern WithLinkage3a withLinkage3a;
extern WithLinkage3b withLinkage3b;
extern WithLinkage4a withLinkage4a;
extern WithLinkage4b withLinkage4b;
extern WithLinkage5 withLinkage5;
extern WithLinkage6 withLinkage6;
extern WithLinkage7 withLinkage7;
extern WithLinkage8 withLinkage8;
extern WithLinkage9 withLinkage9;
extern WithLinkage10 withLinkage10;
// FIXME: These are all ill-formed.
extern WithoutLinkage1 withoutLinkage1;
extern WithoutLinkage2 withoutLinkage2;
extern WithoutLinkage3 withoutLinkage3;
extern WithoutLinkage4 withoutLinkage4;
extern WithoutLinkage5 withoutLinkage5;
// OK, extern "C".
extern "C" {
extern WithoutLinkage1 dr389_withoutLinkage1;
extern WithoutLinkage2 dr389_withoutLinkage2;
extern WithoutLinkage3 dr389_withoutLinkage3;
extern WithoutLinkage4 dr389_withoutLinkage4;
extern WithoutLinkage5 dr389_withoutLinkage5;
}
// OK, defined.
WithoutLinkage1 withoutLinkageDef1;
WithoutLinkage2 withoutLinkageDef2 = WithoutLinkage2();
WithoutLinkage3 withoutLinkageDef3 = {};
WithoutLinkage4 withoutLinkageDef4 = WithoutLinkage4();
WithoutLinkage5 withoutLinkageDef5;
void use(const void *);
void use_all() {
use(&withLinkage1); use(&withLinkage2); use(&withLinkage3a); use(&withLinkage3b);
use(&withLinkage4a); use(&withLinkage4b); use(&withLinkage5); use(&withLinkage6);
use(&withLinkage7); use(&withLinkage8); use(&withLinkage9); use(&withLinkage10);
use(&withoutLinkage1); use(&withoutLinkage2); use(&withoutLinkage3);
use(&withoutLinkage4); use(&withoutLinkage5);
use(&dr389_withoutLinkage1); use(&dr389_withoutLinkage2);
use(&dr389_withoutLinkage3); use(&dr389_withoutLinkage4);
use(&dr389_withoutLinkage5);
use(&withoutLinkageDef1); use(&withoutLinkageDef2); use(&withoutLinkageDef3);
use(&withoutLinkageDef4); use(&withoutLinkageDef5);
}
void local() {
// FIXME: This is ill-formed.
extern WithoutLinkage1 withoutLinkageLocal;
}
}
namespace dr390 { // dr390: yes
template<typename T>
struct A {
A() { f(); } // expected-warning {{call to pure virt}}
virtual void f() = 0; // expected-note {{here}}
virtual ~A() = 0;
};
template<typename T> A<T>::~A() { T::error; } // expected-error {{cannot be used prior to}}
template<typename T> void A<T>::f() { T::error; } // ok, not odr-used
struct B : A<int> { // expected-note 2{{in instantiation of}}
void f() {}
} b;
}
namespace dr391 { // dr391: yes c++11
// FIXME: Should this apply to C++98 too?
class A { A(const A&); }; // expected-note 0-1{{here}}
A fa();
const A &a = fa();
#if __cplusplus < 201103L
// expected-error@-2 {{C++98 requires an accessible copy constructor}}
#endif
struct B { B(const B&) = delete; }; // expected-error 0-1{{extension}} expected-note 0-1{{here}}
B fb();
const B &b = fb();
#if __cplusplus < 201103L
// expected-error@-2 {{deleted}}
#endif
template<typename T>
struct C {
C(const C&) { T::error; }
};
C<int> fc();
const C<int> &c = fc();
}
// dr392 FIXME write codegen test
// dr394: na
namespace dr395 { // dr395: yes
struct S {
template <typename T, int N>(&operator T())[N]; // expected-error {{cannot specify any part of a return type}}
template <typename T, int N> operator(T (&)[N])(); // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error +{{}}
template <typename T> operator T *() const { return 0; }
template <typename T, typename U> operator T U::*() const { return 0; }
template <typename T, typename U> operator T (U::*)()() const { return 0; } // expected-error +{{}}
};
struct null1_t {
template <class T, class U> struct ptr_mem_fun_t {
typedef T (U::*type)();
};
template <class T, class U>
operator typename ptr_mem_fun_t<T, U>::type() const { // expected-note {{couldn't infer}}
return 0;
}
} null1;
int (S::*p)() = null1; // expected-error {{no viable conversion}}
template <typename T> using id = T; // expected-error 0-1{{extension}}
struct T {
template <typename T, int N> operator id<T[N]> &();
template <typename T, typename U> operator id<T (U::*)()>() const;
};
struct null2_t {
template<class T, class U> using ptr_mem_fun_t = T (U::*)(); // expected-error 0-1{{extension}}
template<class T, class U> operator ptr_mem_fun_t<T, U>() const { return 0; };
} null2;
int (S::*q)() = null2;
}
namespace dr396 { // dr396: yes
void f() {
auto int a(); // expected-error {{storage class on function}}
int (i); // expected-note {{previous}}
auto int (i); // expected-error {{redefinition}}
#if __cplusplus >= 201103L
// expected-error@-4 {{'auto' storage class}} expected-error@-2 {{'auto' storage class}}
#endif
}
}
// dr397: sup 1823
namespace dr398 { // dr398: yes
namespace example1 {
struct S {
static int const I = 42;
};
template <int N> struct X {};
template <typename T> void f(X<T::I> *) {}
template <typename T> void f(X<T::J> *) {}
void foo() { f<S>(0); }
}
namespace example2 {
template <int I> struct X {};
template <template <class T> class> struct Z {};
template <class T> void f(typename T::Y *) {} // expected-note 2{{substitution failure}}
template <class T> void g(X<T::N> *) {} // expected-note {{substitution failure}}
template <class T> void h(Z<T::template TT> *) {} // expected-note {{substitution failure}}
struct A {};
struct B {
int Y;
};
struct C {
typedef int N;
};
struct D {
typedef int TT;
};
void test() {
f<A>(0); // expected-error {{no matching function}}
f<B>(0); // expected-error {{no matching function}}
g<C>(0); // expected-error {{no matching function}}
h<D>(0); // expected-error {{no matching function}}
}
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr6xx.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
namespace std { struct type_info {}; }
namespace dr601 { // dr601: yes
#if __cplusplus >= 201103L
#define MAX __LLONG_MAX__
#else
#define MAX __LONG_MAX__
#endif
#if 0x8000 < -1
#error 0x8000 should be signed
#endif
#if MAX > 0xFFFFFFFF && 0x80000000 < -1
#error 0x80000000 should be signed
#endif
#if __INT_MAX__ == 0x7FFFFFFF
_Static_assert(0x80000000 < -1, "0x80000000 should be unsigned"); // expected-error {{C11}}
#endif
#if MAX > 0xFFFFFFFFFFFFFFFF && 0x8000000000000000 < -1
#error 0x8000000000000000 should be signed
#endif
#if __cplusplus >= 201103L && __LLONG_MAX__ == 0x7FFFFFFFFFFFFFFF
static_assert(0x8000000000000000 < -1, "0x8000000000000000 should be unsigned"); // expected-error {{C11}}
#endif
#undef MAX
}
namespace dr602 { // dr602: yes
template<class T> struct A {
template<class U> friend struct A;
};
template<class T> struct B {
class C {
template<class U> friend struct B;
typedef int type;
};
typename C::type ct; // ok, befriended
};
B<int> b;
}
namespace dr603 { // dr603: yes
template<unsigned char> struct S {};
typedef S<'\001'> S1;
typedef S<(1ul << __CHAR_BIT__) + 1> S1;
#if __cplusplus >= 201103L
// expected-error@-2 {{cannot be narrowed}}
#endif
}
// dr604: na
// dr605 needs IRGen test
namespace dr606 { // dr606: yes
#if __cplusplus >= 201103L
template<typename T> struct S {};
template<typename T> void f(S<T> &&); // expected-note {{no known conversion from 'S<int>' to 'S<int> &&'}}
template<typename T> void g(T &&);
template<typename T> void h(const T &&); // expected-note {{no known conversion from 'S<int>' to 'const dr606::S<int> &&'}}
void test(S<int> s) {
f(s); // expected-error {{no match}}
g(s);
h(s); // expected-error {{no match}}
g(test);
h(test); // ok, an rvalue reference can bind to a function lvalue
}
#endif
}
namespace dr608 { // dr608: yes
struct A { virtual void f(); };
struct B : A {};
struct C : A { void f(); };
struct D : B, C {};
}
int dr610[-0u == 0u ? 1 : -1]; // dr610: yes
namespace dr611 { // dr611: yes
int k;
struct S { int &r; } s = { k ? k : k };
}
// dr612: na
namespace dr613 { // dr613: yes c++11
// see also n2253
struct A { int n; static void f(); };
int f(int);
struct B { virtual void f(); };
B &g(int);
int an1 = sizeof(A::n);
int an2 = sizeof(A::n + 1); // valid per dr850
int an3 = sizeof A::n;
int an4 = sizeof(f(A::n));
int an5 = sizeof(g(A::n));
const std::type_info &an6 = typeid(A::n);
const std::type_info &an7 = typeid(A::n + 1);
const std::type_info &an8 = typeid(f(A::n));
const std::type_info &an9 = typeid(g(A::n)); // expected-error {{non-static}}
#if __cplusplus < 201103L
// expected-error@-10 {{non-static}}
// expected-error@-10 {{non-static}}
// expected-error@-10 {{non-static}}
// expected-error@-10 {{non-static}}
// expected-error@-10 {{non-static}}
// expected-error@-10 {{non-static}}
// expected-error@-10 {{non-static}}
// expected-error@-10 {{non-static}}
#endif
void A::f() {
int an1 = sizeof n;
const std::type_info &an2 = typeid(n + 1);
#if __cplusplus < 201103L
// expected-error@-3 {{static}}
// expected-error@-3 {{static}}
#endif
const std::type_info &an3 = typeid(g(n)); // expected-error {{static}}
}
}
int dr614_a[(-1) / 2 == 0 ? 1 : -1]; // dr614: yes
int dr614_b[(-1) % 2 == -1 ? 1 : -1];
namespace dr615 { // dr615: yes
int f();
static int n = f();
}
namespace dr616 { // dr616: no
#if __cplusplus >= 201103L
struct S { int n; } s;
// FIXME: These should all be 'int &&'
using T = decltype(S().n); // expected-note 2{{previous}}
using T = decltype(static_cast<S&&>(s).n);
using T = decltype(S().*&S::n);
using T = decltype(static_cast<S&&>(s).*&S::n); // expected-error {{different type}}
using T = int&&; // expected-error {{different type}}
#endif
}
namespace dr618 { // dr618: yes
#if (unsigned)-1 > 0
#error wrong
#endif
}
namespace dr619 { // dr619: yes
extern int x[10];
struct S { static int x[10]; };
int x[];
_Static_assert(sizeof(x) == sizeof(int) * 10, ""); // expected-error {{C11}}
extern int x[];
_Static_assert(sizeof(x) == sizeof(int) * 10, ""); // expected-error {{C11}}
int S::x[];
_Static_assert(sizeof(S::x) == sizeof(int) * 10, ""); // expected-error {{C11}}
void f() {
extern int x[];
sizeof(x); // expected-error {{incomplete}}
}
}
// dr620: dup 568
namespace dr621 {
template<typename T> T f();
template<> int f() {} // expected-note {{previous}}
template<> int f<int>() {} // expected-error {{redefinition}}
}
// dr623: na
// FIXME: Add documentation saying we allow invalid pointer values.
// dr624 needs an IRGen check.
namespace dr625 { // dr625: yes
template<typename T> struct A {};
A<auto> x = A<int>(); // expected-error {{'auto' not allowed in template argument}} expected-error 0-1{{extension}}
void f(int);
void (*p)(auto) = f; // expected-error {{'auto' not allowed in function prototype}} expected-error 0-1{{extension}}
}
namespace dr626 { // dr626: yes
#define STR(x) #x
char c[2] = STR(c); // ok, type matches
wchar_t w[2] = STR(w); // expected-error {{initializing wide char array with non-wide string literal}}
}
namespace dr627 { // dr627: yes
void f() {
true a = 0; // expected-error +{{}} expected-warning {{unused}}
}
}
// dr628: na
namespace dr629 { // dr629: yes
typedef int T;
int n = 1;
void f() {
auto T = 2;
#if __cplusplus < 201103L
// expected-error@-2 {{expected unqualified-id}}
#else
// expected-note@-4 {{previous}}
#endif
auto T(n);
#if __cplusplus >= 201103L
// expected-error@-2 {{redefinition of 'T'}}
#endif
}
}
namespace dr630 { // dr630: yes
const bool MB_EQ_WC =
' ' == L' ' && '\t' == L'\t' && '\v' == L'\v' && '\r' == L'\r' &&
'\n' == L'\n' && //
'a' == L'a' && 'b' == L'b' && 'c' == L'c' && 'd' == L'd' && 'e' == L'e' &&
'f' == L'f' && 'g' == L'g' && 'h' == L'h' && 'i' == L'i' && 'j' == L'j' &&
'k' == L'k' && 'l' == L'l' && 'm' == L'm' && 'n' == L'n' && 'o' == L'o' &&
'p' == L'p' && 'q' == L'q' && 'r' == L'r' && 's' == L's' && 't' == L't' &&
'u' == L'u' && 'v' == L'v' && 'w' == L'w' && 'x' == L'x' && 'y' == L'y' &&
'z' == L'z' && //
'A' == L'A' && 'B' == L'B' && 'C' == L'C' && 'D' == L'D' && 'E' == L'E' &&
'F' == L'F' && 'G' == L'G' && 'H' == L'H' && 'I' == L'I' && 'J' == L'J' &&
'K' == L'K' && 'L' == L'L' && 'M' == L'M' && 'N' == L'N' && 'O' == L'O' &&
'P' == L'P' && 'Q' == L'Q' && 'R' == L'R' && 'S' == L'S' && 'T' == L'T' &&
'U' == L'U' && 'V' == L'V' && 'W' == L'W' && 'X' == L'X' && 'Y' == L'Y' &&
'Z' == L'Z' && //
'0' == L'0' && '1' == L'1' && '2' == L'2' && '3' == L'3' && '4' == L'4' &&
'5' == L'5' && '6' == L'6' && '7' == L'7' && '8' == L'8' &&
'9' == L'9' && //
'_' == L'_' && '{' == L'{' && '}' == L'}' && '[' == L'[' && ']' == L']' &&
'#' == L'#' && '(' == L'(' && ')' == L')' && '<' == L'<' && '>' == L'>' &&
'%' == L'%' && ':' == L':' && ';' == L';' && '.' == L'.' && '?' == L'?' &&
'*' == L'*' && '+' == L'+' && '-' == L'-' && '/' == L'/' && '^' == L'^' &&
'&' == L'&' && '|' == L'|' && '~' == L'~' && '!' == L'!' && '=' == L'=' &&
',' == L',' && '\\' == L'\\' && '"' == L'"' && '\'' == L'\'';
#if __STDC_MB_MIGHT_NEQ_WC__
#ifndef __FreeBSD__ // PR22208, FreeBSD expects us to give a bad (but conforming) answer here.
_Static_assert(!MB_EQ_WC, "__STDC_MB_MIGHT_NEQ_WC__ but all basic source characters have same representation"); // expected-error {{C11}}
#endif
#else
_Static_assert(MB_EQ_WC, "!__STDC_MB_MIGHT_NEQ_WC__ but some character differs"); // expected-error {{C11}}
#endif
}
// dr631: na
namespace dr632 { // dr632: yes
struct S { int n; } s = {{5}}; // expected-warning {{braces}}
}
// dr633: na
// see also n2993
namespace dr634 { // dr634: yes
struct S { S(); S(const S&); virtual void f(); ~S(); };
int f(...);
char f(int);
template<typename T> int (&g(T))[sizeof f(T())];
int (&a)[sizeof(int)] = g(S());
int (&b)[1] = g(0);
int k = f(S()); // expected-error {{cannot pass}}
}
namespace dr635 { // dr635: yes
template<typename T> struct A { A(); ~A(); };
template<typename T> A<T>::A<T>() {} // expected-error {{cannot have template arguments}}
template<typename T> A<T>::~A<T>() {}
template<typename T> struct B { B(); ~B(); };
template<typename T> B<T>::B() {}
template<typename T> B<T>::~B() {}
struct C { template<typename T> C(); C(); };
template<typename T> C::C() {}
C::C() {}
template<> C::C<int>() {} // expected-error {{constructor name}} expected-error {{unqualified-id}}
/*FIXME: needed for error recovery:*/;
template<typename T> struct D { template<typename U> D(); D(); };
template<typename T> D<T>::D() {} // expected-note {{previous}}
template<typename T> template<typename U> D<T>::D() {}
template<typename T> D<T>::D<T>() {} // expected-error {{redefinition}} expected-error {{cannot have template arg}}
}
namespace dr637 { // dr637: yes
void f(int i) {
i = ++i + 1;
i = i++ + 1; // expected-warning {{unsequenced}}
}
}
namespace dr638 { // dr638: no
template<typename T> struct A {
struct B;
void f();
void g();
struct C {
void h();
};
};
class X {
typedef int type;
template<class T> friend struct A<T>::B; // expected-warning {{not supported}}
template<class T> friend void A<T>::f(); // expected-warning {{not supported}}
template<class T> friend void A<T>::g(); // expected-warning {{not supported}}
template<class T> friend void A<T>::C::h(); // expected-warning {{not supported}}
};
template<> struct A<int> {
X::type a; // FIXME: private
struct B {
X::type b; // ok
};
int f() { X::type c; } // FIXME: private
void g() { X::type d; } // ok
struct D {
void h() { X::type e; } // FIXME: private
};
};
}
namespace dr639 { // dr639: yes
void f(int i) {
void((i = 0) + (i = 0)); // expected-warning {{unsequenced}}
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr1xx.cpp
|
// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
namespace dr100 { // dr100: yes
template<const char *> struct A {}; // expected-note 0-1{{declared here}}
template<const char (&)[4]> struct B {}; // expected-note 0-1{{declared here}}
A<"foo"> a; // expected-error {{does not refer to any declaration}}
B<"bar"> b; // expected-error {{does not refer to any declaration}}
}
namespace dr101 { // dr101: 3.5
extern "C" void dr101_f();
typedef unsigned size_t;
namespace X {
extern "C" void dr101_f();
typedef unsigned size_t;
}
using X::dr101_f;
using X::size_t;
extern "C" void dr101_f();
typedef unsigned size_t;
}
namespace dr102 { // dr102: yes
namespace A {
template<typename T> T f(T a, T b) { return a + b; } // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}}
}
namespace B {
struct S {};
}
B::S operator+(B::S, B::S); // expected-note {{should be declared prior to the call site or in namespace 'dr102::B'}}
template B::S A::f(B::S, B::S); // expected-note {{in instantiation of}}
}
// dr103: na
// dr104 FIXME: add codegen test
// dr105: na
namespace dr106 { // dr106: sup 540
typedef int &r1;
typedef r1 &r1;
typedef const r1 r1; // expected-warning {{has no effect}}
typedef const r1 &r1; // expected-warning {{has no effect}}
typedef const int &r2;
typedef r2 &r2;
typedef const r2 r2; // expected-warning {{has no effect}}
typedef const r2 &r2; // expected-warning {{has no effect}}
}
namespace dr107 { // dr107: yes
struct S {};
extern "C" S operator+(S, S) { return S(); }
}
namespace dr108 { // dr108: yes
template<typename T> struct A {
struct B { typedef int X; };
B::X x; // expected-error {{missing 'typename'}}
struct C : B { X x; }; // expected-error {{unknown type name}}
};
template<> struct A<int>::B { int X; };
}
namespace dr109 { // dr109: yes
struct A { template<typename T> void f(T); };
template<typename T> struct B : T {
using T::template f; // expected-error {{using declaration cannot refer to a template}}
void g() { this->f<int>(123); } // expected-error {{use 'template'}}
};
}
namespace dr111 { // dr111: dup 535
struct A { A(); A(volatile A&, int = 0); A(A&, const char * = "foo"); };
struct B : A { B(); }; // expected-note +{{would lose const qualifier}} expected-note {{requires 0 arguments}}
const B b1;
B b2(b1); // expected-error {{no matching constructor}}
}
namespace dr112 { // dr112: yes
struct T { int n; };
typedef T Arr[1];
const T a1[1] = {};
volatile T a2[1] = {};
const Arr a3 = {};
volatile Arr a4 = {};
template<const volatile T*> struct X {};
X<a1> x1;
X<a2> x2;
X<a3> x3;
X<a4> x4;
#if __cplusplus < 201103L
// expected-error@-5 {{internal linkage}} expected-note@-10 {{here}}
// expected-error@-4 {{internal linkage}} expected-note@-9 {{here}}
#else
// FIXME: Test this somehow.
#endif
}
namespace dr113 { // dr113: yes
extern void (*p)();
void f() {
no_such_function(); // expected-error {{undeclared}}
p();
}
void g();
void (*p)() = &g;
}
namespace dr114 { // dr114: yes
struct A {
virtual void f(int) = 0; // expected-note {{unimplemented}}
};
struct B : A {
template<typename T> void f(T);
void g() { f(0); }
} b; // expected-error {{abstract}}
}
namespace dr115 { // dr115: yes
template<typename T> int f(T); // expected-note +{{}}
template<typename T> int g(T); // expected-note +{{}}
template<typename T> int g(T, int); // expected-note +{{}}
int k1 = f(&f); // expected-error {{no match}}
int k2 = f(&f<int>);
int k3 = f(&g<int>); // expected-error {{no match}}
void h() {
(void)&f; // expected-error {{address of overloaded function 'f' cannot be cast to type 'void'}}
(void)&f<int>;
(void)&g<int>; // expected-error {{address of overloaded function 'g' cannot be cast to type 'void'}}
&f; // expected-error {{reference to overloaded function could not be resolved}}
&f<int>; // expected-warning {{unused}}
&g<int>; // expected-error {{reference to overloaded function could not be resolved}}
}
struct S {
template<typename T> static int f(T);
template<typename T> static int g(T);
template<typename T> static int g(T, int);
} s;
int k4 = f(&s.f); // expected-error {{non-constant pointer to member}}
int k5 = f(&s.f<int>);
int k6 = f(&s.g<int>); // expected-error {{non-constant pointer to member}}
void i() {
(void)&s.f; // expected-error {{non-constant pointer to member}}
(void)&s.f<int>;
(void)&s.g<int>; // expected-error {{non-constant pointer to member}}
&s.f; // expected-error {{non-constant pointer to member}}
&s.f<int>; // expected-warning {{unused}}
&s.g<int>; // expected-error {{non-constant pointer to member}}
}
struct T {
template<typename T> int f(T);
template<typename T> int g(T);
template<typename T> int g(T, int);
} t;
int k7 = f(&s.f); // expected-error {{non-constant pointer to member}}
int k8 = f(&s.f<int>);
int k9 = f(&s.g<int>); // expected-error {{non-constant pointer to member}}
void j() {
(void)&s.f; // expected-error {{non-constant pointer to member}}
(void)&s.f<int>;
(void)&s.g<int>; // expected-error {{non-constant pointer to member}}
&s.f; // expected-error {{non-constant pointer to member}}
&s.f<int>; // expected-warning {{unused}}
&s.g<int>; // expected-error {{non-constant pointer to member}}
}
#if __cplusplus >= 201103L
// Special case kicks in only if a template argument list is specified.
template<typename T=int> void with_default(); // expected-note +{{}}
int k10 = f(&with_default); // expected-error {{no matching function}}
int k11 = f(&with_default<>);
void k() {
(void)&with_default; // expected-error {{overloaded function}}
(void)&with_default<>;
&with_default; // expected-error {{overloaded function}}
&with_default<>; // expected-warning {{unused}}
}
#endif
}
namespace dr116 { // dr116: yes
template<int> struct A {};
template<int N> void f(A<N>) {} // expected-note {{previous}}
template<int M> void f(A<M>) {} // expected-error {{redefinition}}
template<typename T> void f(A<sizeof(T)>) {} // expected-note {{previous}}
template<typename U> void f(A<sizeof(U)>) {} // expected-error {{redefinition}}
}
// dr117: na
// dr118 FIXME: add codegen test
// dr119: na
// dr120: na
namespace dr121 { // dr121: yes
struct X {
template<typename T> struct Y {};
};
template<typename T> struct Z {
X::Y<T> x;
T::Y<T> y; // expected-error +{{}}
};
Z<X> z;
}
namespace dr122 { // dr122: yes
template<typename T> void f();
void g() { f<int>(); }
}
// dr123: na
// dr124: dup 201
// dr125: yes
struct dr125_A { struct dr125_B {}; }; // expected-note {{here}}
dr125_A::dr125_B dr125_C();
namespace dr125_B { dr125_A dr125_C(); }
namespace dr125 {
struct X {
friend dr125_A::dr125_B (::dr125_C)(); // ok
friend dr125_A (::dr125_B::dr125_C)(); // ok
friend dr125_A::dr125_B::dr125_C(); // expected-error {{did you mean the constructor name 'dr125_B'?}}
// expected-warning@-1 {{missing exception specification}}
#if __cplusplus >= 201103L
// expected-error@-3 {{follows constexpr declaration}} expected-note@-10 {{here}}
#endif
};
}
namespace dr126 { // dr126: no
struct C {};
struct D : C {};
struct E : private C { friend class A; friend class B; };
struct F : protected C {};
struct G : C {};
struct H : D, G {};
struct A {
virtual void cp() throw(C*);
virtual void dp() throw(C*);
virtual void ep() throw(C*); // expected-note {{overridden}}
virtual void fp() throw(C*); // expected-note {{overridden}}
virtual void gp() throw(C*);
virtual void hp() throw(C*); // expected-note {{overridden}}
virtual void cr() throw(C&);
virtual void dr() throw(C&);
virtual void er() throw(C&); // expected-note {{overridden}}
virtual void fr() throw(C&); // expected-note {{overridden}}
virtual void gr() throw(C&);
virtual void hr() throw(C&); // expected-note {{overridden}}
virtual void pv() throw(void*); // expected-note {{overridden}}
#if __cplusplus >= 201103L
virtual void np() throw(C*); // expected-note {{overridden}}
virtual void npm() throw(int C::*); // expected-note {{overridden}}
virtual void nr() throw(C&); // expected-note {{overridden}}
#endif
virtual void ref1() throw(C *const&);
virtual void ref2() throw(C *);
virtual void v() throw(int);
virtual void w() throw(const int);
virtual void x() throw(int*);
virtual void y() throw(const int*);
virtual void z() throw(int); // expected-note {{overridden}}
};
struct B : A {
virtual void cp() throw(C*);
virtual void dp() throw(D*);
virtual void ep() throw(E*); // expected-error {{more lax}}
virtual void fp() throw(F*); // expected-error {{more lax}}
virtual void gp() throw(G*);
virtual void hp() throw(H*); // expected-error {{more lax}}
virtual void cr() throw(C&);
virtual void dr() throw(D&);
virtual void er() throw(E&); // expected-error {{more lax}}
virtual void fr() throw(F&); // expected-error {{more lax}}
virtual void gr() throw(G&);
virtual void hr() throw(H&); // expected-error {{more lax}}
virtual void pv() throw(C*); // expected-error {{more lax}} FIXME: This is valid.
#if __cplusplus >= 201103L
using nullptr_t = decltype(nullptr);
virtual void np() throw(nullptr_t*); // expected-error {{more lax}} FIXME: This is valid.
virtual void npm() throw(nullptr_t*); // expected-error {{more lax}} FIXME: This is valid.
virtual void nr() throw(nullptr_t&); // expected-error {{more lax}} This is not.
#endif
virtual void ref1() throw(D *const &);
virtual void ref2() throw(D *);
virtual void v() throw(const int);
virtual void w() throw(int);
virtual void x() throw(const int*); // FIXME: 'const int*' is not allowed by A::h.
virtual void y() throw(int*); // ok
virtual void z() throw(long); // expected-error {{more lax}}
};
}
namespace dr127 { // dr127: yes
__extension__ typedef __decltype(sizeof(0)) size_t;
template<typename T> struct A {
A() throw(int);
void *operator new(size_t, const char * = 0);
void operator delete(void *, const char *) { T::error; } // expected-error 2{{no members}}
void operator delete(void *) { T::error; }
};
A<void> *p = new A<void>; // expected-note {{instantiat}}
A<int> *q = new ("") A<int>; // expected-note {{instantiat}}
}
namespace dr128 { // dr128: yes
enum E1 { e1 } x = e1;
enum E2 { e2 } y = static_cast<E2>(x), z = static_cast<E2>(e1);
}
// dr129: dup 616
// dr130: na
namespace dr131 { // dr131: yes
const char *a_with_\u0e8c = "\u0e8c";
const char *b_with_\u0e8d = "\u0e8d";
const char *c_with_\u0e8e = "\u0e8e";
#if __cplusplus < 201103L
// expected-error@-4 {{expected ';'}} expected-error@-2 {{expected ';'}}
#endif
}
namespace dr132 { // dr132: no
void f() {
extern struct {} x; // ok
extern struct S {} y; // FIXME: This is invalid.
}
static enum { E } e;
}
// dr133: dup 87
// dr134: na
namespace dr135 { // dr135: yes
struct A {
A f(A a) { return a; }
friend A g(A a) { return a; }
static A h(A a) { return a; }
};
}
namespace dr136 { // dr136: 3.4
void f(int, int, int = 0); // expected-note {{previous declaration is here}}
void g(int, int, int); // expected-note {{previous declaration is here}}
struct A {
friend void f(int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
friend void g(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
friend void h(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be a definition}}
friend void i(int, int, int = 0) {} // expected-note {{previous declaration is here}}
friend void j(int, int, int = 0) {}
operator int();
};
void i(int, int, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
void q() {
j(A(), A()); // ok, has default argument
}
extern "C" void k(int, int, int, int); // expected-note {{previous declaration is here}}
namespace NSA {
struct A {
friend void dr136::k(int, int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} \
// expected-note {{previous declaration is here}}
};
}
namespace NSB {
struct A {
friend void dr136::k(int, int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
};
}
struct B {
void f(int); // expected-note {{previous declaration is here}}
};
struct C {
friend void B::f(int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}}
};
}
namespace dr137 { // dr137: yes
extern void *p;
extern const void *cp;
extern volatile void *vp;
extern const volatile void *cvp;
int *q = static_cast<int*>(p);
int *qc = static_cast<int*>(cp); // expected-error {{casts away qualifiers}}
int *qv = static_cast<int*>(vp); // expected-error {{casts away qualifiers}}
int *qcv = static_cast<int*>(cvp); // expected-error {{casts away qualifiers}}
const int *cq = static_cast<const int*>(p);
const int *cqc = static_cast<const int*>(cp);
const int *cqv = static_cast<const int*>(vp); // expected-error {{casts away qualifiers}}
const int *cqcv = static_cast<const int*>(cvp); // expected-error {{casts away qualifiers}}
const volatile int *cvq = static_cast<const volatile int*>(p);
const volatile int *cvqc = static_cast<const volatile int*>(cp);
const volatile int *cvqv = static_cast<const volatile int*>(vp);
const volatile int *cvqcv = static_cast<const volatile int*>(cvp);
}
namespace dr139 { // dr139: yes
namespace example1 {
typedef int f; // expected-note {{previous}}
struct A {
friend void f(A &); // expected-error {{different kind of symbol}}
};
}
namespace example2 {
typedef int f;
namespace N {
struct A {
friend void f(A &);
operator int();
void g(A a) { int i = f(a); } // ok, f is typedef not friend function
};
}
}
}
namespace dr140 { // dr140: yes
void f(int *const) {} // expected-note {{previous}}
void f(int[3]) {} // expected-error {{redefinition}}
void g(const int);
void g(int n) { n = 2; }
}
namespace dr141 { // dr141: yes
template<typename T> void f();
template<typename T> struct S { int n; };
struct A : S<int> {
template<typename T> void f();
template<typename T> struct S {};
} a;
struct B : S<int> {} b;
void g() {
a.f<int>();
(void)a.S<int>::n; // expected-error {{no member named 'n'}}
#if __cplusplus < 201103L
// expected-error@-2 {{ambiguous}}
// expected-note@-11 {{lookup from the current scope}}
// expected-note@-9 {{lookup in the object type}}
#endif
b.f<int>(); // expected-error {{no member}} expected-error +{{}}
(void)b.S<int>::n;
}
template<typename T> struct C {
T t;
void g() {
t.f<int>(); // expected-error {{use 'template'}}
}
void h() {
(void)t.S<int>::n; // ok
}
void i() {
(void)t.S<int>(); // ok!
}
};
void h() { C<B>().h(); } // ok
struct X {
template<typename T> void S();
};
void i() { C<X>().i(); } // ok!!
}
namespace dr142 { // dr142: yes
class B { // expected-note +{{here}}
public:
int mi; // expected-note +{{here}}
static int si; // expected-note +{{here}}
};
class D : private B { // expected-note +{{here}}
};
class DD : public D {
void f();
};
void DD::f() {
mi = 3; // expected-error {{private base class}} expected-error {{private member}}
si = 3; // expected-error {{private member}}
B b_old; // expected-error {{private member}}
dr142::B b;
b.mi = 3;
b.si = 3;
B::si = 3; // expected-error {{private member}}
dr142::B::si = 3;
B *bp1_old = this; // expected-error {{private member}} expected-error {{private base class}}
dr142::B *bp1 = this; // expected-error {{private base class}}
B *bp2_old = (B*)this; // expected-error 2{{private member}}
dr142::B *bp2 = (dr142::B*)this;
bp2->mi = 3;
}
}
namespace dr143 { // dr143: yes
namespace A { struct X; }
namespace B { void f(A::X); }
namespace A {
struct X { friend void B::f(X); };
}
void g(A::X x) {
f(x); // expected-error {{undeclared identifier 'f'}}
}
}
namespace dr145 { // dr145: yes
void f(bool b) {
++b; // expected-warning {{deprecated}}
b++; // expected-warning {{deprecated}}
}
}
namespace dr147 { // dr147: no
namespace example1 {
template<typename> struct A {
template<typename T> A(T);
};
// FIXME: This appears to be valid, and EDG and G++ accept.
template<> template<> A<int>::A<int>(int) {} // expected-error {{out-of-line constructor for 'A' cannot have template arguments}}
}
namespace example2 {
struct A { A(); };
struct B : A { B(); };
A::A a1; // expected-error {{is a constructor}}
B::A a2;
}
namespace example3 {
template<typename> struct A {
template<typename T> A(T);
static A a;
};
template<> A<int>::A<int>(A<int>::a); // expected-error {{is a constructor}}
}
}
namespace dr148 { // dr148: yes
struct A { int A::*p; };
int check1[__is_pod(int(A::*)) ? 1 : -1];
int check2[__is_pod(A) ? 1 : -1];
}
// dr149: na
namespace dr151 { // dr151: yes
struct X {};
typedef int X::*p;
#if __cplusplus < 201103L
#define fold(x) (__builtin_constant_p(0) ? (x) : (x))
#else
#define fold
#endif
int check[fold(p() == 0) ? 1 : -1];
#undef fold
}
namespace dr152 { // dr152: yes
struct A {
A(); // expected-note {{not viable}}
explicit A(const A&);
};
A a1 = A(); // expected-error {{no matching constructor}}
A a2((A()));
}
// dr153: na
namespace dr154 { // dr154: yes
union { int a; }; // expected-error {{must be declared 'static'}}
namespace {
union { int b; };
}
static union { int c; };
}
namespace dr155 { // dr155: dup 632
struct S { int n; } s = { { 1 } }; // expected-warning {{braces around scalar initializer}}
}
// dr158 FIXME write codegen test
namespace dr159 { // dr159: 3.5
namespace X { void f(); }
void f();
void dr159::f() {} // expected-warning {{extra qualification}}
void dr159::X::f() {}
}
// dr160: na
namespace dr161 { // dr161: yes
class A {
protected:
struct B { int n; } b; // expected-note 2{{here}}
static B bs;
void f(); // expected-note {{here}}
static void sf();
};
struct C : A {};
struct D : A {
void g(C c) {
(void)b.n;
B b1;
C::B b2; // ok, accessible as a member of A
(void)&C::b; // expected-error {{protected}}
(void)&C::bs;
(void)c.b; // expected-error {{protected}}
(void)c.bs;
f();
sf();
c.f(); // expected-error {{protected}}
c.sf();
A::f();
D::f();
A::sf();
C::sf();
D::sf();
}
};
}
namespace dr162 { // dr162: no
struct A {
char &f(char);
static int &f(int);
void g() {
int &a = (&A::f)(0); // FIXME: expected-error {{could not be resolved}}
char &b = (&A::f)('0'); // expected-error {{could not be resolved}}
}
};
int &c = (&A::f)(0); // FIXME: expected-error {{could not be resolved}}
char &d = (&A::f)('0'); // expected-error {{could not be resolved}}
}
// dr163: na
namespace dr164 { // dr164: yes
void f(int);
template <class T> int g(T t) { return f(t); }
enum E { e };
int f(E);
int k = g(e);
}
namespace dr165 { // dr165: no
namespace N {
struct A { friend struct B; };
void f() { void g(); }
}
// FIXME: dr1477 says this is ok, dr165 says it's ill-formed
struct N::B {};
// FIXME: dr165 says this is ill-formed, but the argument in dr1477 says it's ok
void N::g() {}
}
namespace dr166 { // dr166: yes
namespace A { class X; }
template<typename T> int f(T t) { return t.n; }
int g(A::X);
template<typename T> int h(T t) { return t.n; } // expected-error {{private}}
int i(A::X);
namespace A {
class X {
friend int f<X>(X);
friend int dr166::g(X);
friend int h(X);
friend int i(X);
int n; // expected-note 2{{here}}
};
int h(X x) { return x.n; }
int i(X x) { return x.n; }
}
template int f(A::X);
int g(A::X x) { return x.n; }
template int h(A::X); // expected-note {{instantiation}}
int i(A::X x) { return x.n; } // expected-error {{private}}
}
// dr167: sup 1012
namespace dr168 { // dr168: no
extern "C" typedef int (*p)();
extern "C++" typedef int (*q)();
struct S {
static int f();
};
p a = &S::f; // FIXME: this should fail.
q b = &S::f;
}
namespace dr169 { // dr169: yes
template<typename> struct A { int n; };
struct B {
template<typename> struct C;
template<typename> void f();
template<typename> static int n; // expected-error 0-1{{extension}}
};
struct D : A<int>, B {
using A<int>::n;
using B::C<int>; // expected-error {{using declaration cannot refer to a template specialization}}
using B::f<int>; // expected-error {{using declaration cannot refer to a template specialization}}
using B::n<int>; // expected-error {{using declaration cannot refer to a template specialization}}
};
}
namespace { // dr171: yes
int dr171a;
}
int dr171b; // expected-note {{here}}
namespace dr171 {
extern "C" void dr171a();
extern "C" void dr171b(); // expected-error {{conflicts}}
}
namespace dr172 { // dr172: yes
enum { zero };
int check1[-1 < zero ? 1 : -1];
enum { x = -1, y = (unsigned int)-1 };
int check2[sizeof(x) > sizeof(int) ? 1 : -1];
enum { a = (unsigned int)-1 / 2 };
int check3a[sizeof(a) == sizeof(int) ? 1 : -1];
int check3b[-a < 0 ? 1 : -1];
enum { b = (unsigned int)-1 / 2 + 1 };
int check4a[sizeof(b) == sizeof(unsigned int) ? 1 : -1];
int check4b[-b > 0 ? 1 : -1];
enum { c = (unsigned long)-1 / 2 };
int check5a[sizeof(c) == sizeof(long) ? 1 : -1];
int check5b[-c < 0 ? 1 : -1];
enum { d = (unsigned long)-1 / 2 + 1 };
int check6a[sizeof(d) == sizeof(unsigned long) ? 1 : -1];
int check6b[-d > 0 ? 1 : -1];
enum { e = (unsigned long long)-1 / 2 }; // expected-error 0-1{{extension}}
int check7a[sizeof(e) == sizeof(long) ? 1 : -1]; // expected-error 0-1{{extension}}
int check7b[-e < 0 ? 1 : -1];
enum { f = (unsigned long long)-1 / 2 + 1 }; // expected-error 0-1{{extension}}
int check8a[sizeof(f) == sizeof(unsigned long) ? 1 : -1]; // expected-error 0-1{{extension}}
int check8b[-f > 0 ? 1 : -1];
}
namespace dr173 { // dr173: yes
int check[('0' + 1 == '1' && '0' + 2 == '2' && '0' + 3 == '3' &&
'0' + 4 == '4' && '0' + 5 == '5' && '0' + 6 == '6' &&
'0' + 7 == '7' && '0' + 8 == '8' && '0' + 9 == '9') ? 1 : -1];
}
// dr174: sup 1012
namespace dr175 { // dr175: yes
struct A {}; // expected-note {{here}}
struct B : private A {}; // expected-note {{constrained by private inheritance}}
struct C : B {
A a; // expected-error {{private}}
dr175::A b;
};
}
namespace dr176 { // dr176: yes
template<typename T> class Y;
template<> class Y<int> {
void f() {
typedef Y A; // expected-note {{here}}
typedef Y<char> A; // expected-error {{different types ('Y<char>' vs 'Y<int>')}}
}
};
template<typename T> struct Base {}; // expected-note 2{{found}}
template<typename T> struct Derived : public Base<T> {
void f() {
typedef typename Derived::template Base<T> A;
typedef typename Derived::Base A;
}
};
template struct Derived<int>;
template<typename T> struct Derived2 : Base<int>, Base<char> {
typename Derived2::Base b; // expected-error {{found in multiple base classes}}
typename Derived2::Base<double> d;
};
template<typename T> class X { // expected-note {{here}}
X *p1;
X<T> *p2;
X<int> *p3;
dr176::X *p4; // expected-error {{requires template arguments}}
};
}
namespace dr177 { // dr177: yes
struct B {};
struct A {
A(A &); // expected-note {{not viable: expects an l-value}}
A(const B &);
};
B b;
A a = b; // expected-error {{no viable constructor copying variable}}
}
namespace dr178 { // dr178: yes
int check[int() == 0 ? 1 : -1];
#if __cplusplus >= 201103L
static_assert(int{} == 0, "");
struct S { int a, b; };
static_assert(S{1}.b == 0, "");
struct T { constexpr T() : n() {} int n; };
static_assert(T().n == 0, "");
struct U : S { constexpr U() : S() {} };
static_assert(U().b == 0, "");
#endif
}
namespace dr179 { // dr179: yes
void f();
int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}}
}
namespace dr180 { // dr180: yes
template<typename T> struct X : T, T::some_base {
X() : T::some_type_that_might_be_T(), T::some_base() {}
friend class T::some_class;
void f() {
enum T::some_enum e;
}
};
}
namespace dr181 { // dr181: yes
namespace X {
template <template X<class T> > struct A { }; // expected-error +{{}}
template <template X<class T> > void f(A<X>) { } // expected-error +{{}}
}
namespace Y {
template <template <class T> class X> struct A { };
template <template <class T> class X> void f(A<X>) { }
}
}
namespace dr182 { // dr182: yes
template <class T> struct C {
void f();
void g();
};
template <class T> void C<T>::f() {}
template <class T> void C<T>::g() {}
class A {
class B {}; // expected-note {{here}}
void f();
};
template void C<A::B>::f();
template <> void C<A::B>::g(); // expected-error {{private}}
void A::f() {
C<B> cb;
cb.f();
}
}
namespace dr183 { // dr183: sup 382
template<typename T> struct A {};
template<typename T> struct B {
typedef int X;
};
template<> struct A<int> {
typename B<int>::X x;
};
}
namespace dr184 { // dr184: yes
template<typename T = float> struct B {};
template<template<typename TT = float> class T> struct A {
void f();
void g();
};
template<template<typename TT> class T> void A<T>::f() { // expected-note {{here}}
T<> t; // expected-error {{too few template arguments}}
}
template<template<typename TT = char> class T> void A<T>::g() {
T<> t;
typedef T<> X;
typedef T<char> X;
}
void h() { A<B>().g(); }
}
// dr185 FIXME: add codegen test
namespace dr187 { // dr187: sup 481
const int Z = 1;
template<int X = Z, int Z = X> struct A;
typedef A<> T;
typedef A<1, 1> T;
}
namespace dr188 { // dr188: yes
char c[10];
int check[sizeof(0, c) == 10 ? 1 : -1];
}
// dr190 FIXME: add codegen test for tbaa
// dr193 FIXME: add codegen test
namespace dr194 { // dr194: yes
struct A {
A();
void A(); // expected-error {{constructor cannot have a return type}}
};
struct B {
void B(); // expected-error {{constructor cannot have a return type}}
B();
};
struct C {
inline explicit C(int) {}
};
}
namespace dr195 { // dr195: yes
void f();
int *p = (int*)&f; // expected-error 0-1{{extension}}
void (*q)() = (void(*)())&p; // expected-error 0-1{{extension}}
}
namespace dr197 { // dr197: yes
char &f(char);
template <class T> void g(T t) {
char &a = f(1);
char &b = f(T(1)); // expected-error {{unrelated type 'int'}}
char &c = f(t); // expected-error {{unrelated type 'int'}}
}
void f(int);
enum E { e };
int &f(E);
void h() {
g('a');
g(2);
g(e); // expected-note {{in instantiation of}}
}
}
namespace dr198 { // dr198: yes
struct A {
int n;
struct B {
int m[sizeof(n)];
#if __cplusplus < 201103L
// expected-error@-2 {{invalid use of non-static data member}}
#endif
int f() { return n; }
// expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'B'}}
};
struct C;
struct D;
};
struct A::C {
int m[sizeof(n)];
#if __cplusplus < 201103L
// expected-error@-2 {{invalid use of non-static data member}}
#endif
int f() { return n; }
// expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'C'}}
};
struct A::D : A {
int m[sizeof(n)];
#if __cplusplus < 201103L
// expected-error@-2 {{invalid use of non-static data member}}
#endif
int f() { return n; }
};
}
// dr199 FIXME: add codegen test
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr0xx.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -Wno-bind-to-temporary-copy
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
namespace dr1 { // dr1: no
namespace X { extern "C" void dr1_f(int a = 1); }
namespace Y { extern "C" void dr1_f(int a = 1); }
using X::dr1_f; using Y::dr1_f;
void g() {
dr1_f(0);
// FIXME: This should be rejected, due to the ambiguous default argument.
dr1_f();
}
namespace X {
using Y::dr1_f;
void h() {
dr1_f(0);
// FIXME: This should be rejected, due to the ambiguous default argument.
dr1_f();
}
}
namespace X {
void z(int);
}
void X::z(int = 1) {} // expected-note {{previous}}
namespace X {
void z(int = 1); // expected-error {{redefinition of default argument}}
}
void i(int = 1);
void j() {
void i(int = 1);
using dr1::i;
i(0);
// FIXME: This should be rejected, due to the ambiguous default argument.
i();
}
void k() {
using dr1::i;
void i(int = 1);
i(0);
// FIXME: This should be rejected, due to the ambiguous default argument.
i();
}
}
namespace dr3 { // dr3: yes
template<typename T> struct A {};
template<typename T> void f(T) { A<T> a; } // expected-note {{implicit instantiation}}
template void f(int);
template<> struct A<int> {}; // expected-error {{explicit specialization of 'dr3::A<int>' after instantiation}}
}
namespace dr4 { // dr4: yes
extern "C" {
static void dr4_f(int) {}
static void dr4_f(float) {}
void dr4_g(int) {} // expected-note {{previous}}
void dr4_g(float) {} // expected-error {{conflicting types}}
}
}
namespace dr5 { // dr5: yes
struct A {} a;
struct B {
B(const A&);
B(const B&);
};
const volatile B b = a;
struct C { C(C&); };
struct D : C {};
struct E { operator D&(); } e;
const C c = e;
}
namespace dr7 { // dr7: yes
class A { public: ~A(); };
class B : virtual private A {}; // expected-note 2 {{declared private here}}
class C : public B {} c; // expected-error 2 {{inherited virtual base class 'dr7::A' has private destructor}} \
// expected-note {{implicit default constructor for 'dr7::C' first required here}} \
// expected-note {{implicit destructor for 'dr7::C' first required here}}
class VeryDerivedC : public B, virtual public A {} vdc;
class X { ~X(); }; // expected-note {{here}}
class Y : X { ~Y() {} }; // expected-error {{private destructor}}
namespace PR16370 { // This regressed the first time DR7 was fixed.
struct S1 { virtual ~S1(); };
struct S2 : S1 {};
struct S3 : S2 {};
struct S4 : virtual S2 {};
struct S5 : S3, S4 {
S5();
~S5();
};
S5::S5() {}
}
}
namespace dr8 { // dr8: dup 45
class A {
struct U;
static const int k = 5;
void f();
template<typename, int, void (A::*)()> struct T;
T<U, k, &A::f> *g();
};
A::T<A::U, A::k, &A::f> *A::g() { return 0; }
}
namespace dr9 { // dr9: yes
struct B {
protected:
int m; // expected-note {{here}}
friend int R1();
};
struct N : protected B { // expected-note 2{{protected}}
friend int R2();
} n;
int R1() { return n.m; } // expected-error {{protected base class}} expected-error {{protected member}}
int R2() { return n.m; }
}
namespace dr10 { // dr10: dup 45
class A {
struct B {
A::B *p;
};
};
}
namespace dr11 { // dr11: yes
template<typename T> struct A : T {
using typename T::U;
U u;
};
template<typename T> struct B : T {
using T::V;
V v; // expected-error {{unknown type name}}
};
struct X { typedef int U; };
A<X> ax;
}
namespace dr12 { // dr12: sup 239
enum E { e };
E &f(E, E = e);
void g() {
int &f(int, E = e);
// Under DR12, these call two different functions.
// Under DR239, they call the same function.
int &b = f(e);
int &c = f(1);
}
}
namespace dr13 { // dr13: no
extern "C" void f(int);
void g(char);
template<typename T> struct A {
A(void (*fp)(T));
};
template<typename T> int h(void (T));
A<int> a1(f); // FIXME: We should reject this.
A<char> a2(g);
int a3 = h(f); // FIXME: We should reject this.
int a4 = h(g);
}
namespace dr14 { // dr14: yes
namespace X { extern "C" int dr14_f(); }
namespace Y { extern "C" int dr14_f(); }
using namespace X;
using namespace Y;
int k = dr14_f();
class C {
int k;
friend int Y::dr14_f();
} c;
namespace Z {
extern "C" int dr14_f() { return c.k; }
}
namespace X { typedef int T; typedef int U; } // expected-note {{candidate}}
namespace Y { typedef int T; typedef long U; } // expected-note {{candidate}}
T t; // ok, same type both times
U u; // expected-error {{ambiguous}}
}
namespace dr15 { // dr15: yes
template<typename T> void f(int); // expected-note {{previous}}
template<typename T> void f(int = 0); // expected-error {{default arguments cannot be added}}
}
namespace dr16 { // dr16: yes
class A { // expected-note {{here}}
void f(); // expected-note {{here}}
friend class C;
};
class B : A {}; // expected-note 4{{here}}
class C : B {
void g() {
f(); // expected-error {{private member}} expected-error {{private base}}
A::f(); // expected-error {{private member}} expected-error {{private base}}
}
};
}
namespace dr17 { // dr17: yes
class A {
int n;
int f();
struct C;
};
struct B : A {} b;
int A::f() { return b.n; }
struct A::C : A {
int g() { return n; }
};
}
// dr18: sup 577
namespace dr19 { // dr19: yes
struct A {
int n; // expected-note {{here}}
};
struct B : protected A { // expected-note {{here}}
};
struct C : B {} c;
struct D : B {
int get1() { return c.n; } // expected-error {{protected member}}
int get2() { return ((A&)c).n; } // ok, A is an accessible base of B from here
};
}
namespace dr20 { // dr20: yes
class X {
public:
X();
private:
X(const X&); // expected-note {{here}}
};
X f();
X x = f(); // expected-error {{private}}
}
namespace dr21 { // dr21: yes
template<typename T> struct A;
struct X {
template<typename T = int> friend struct A; // expected-error {{default template argument not permitted on a friend template}}
template<typename T = int> friend struct B; // expected-error {{default template argument not permitted on a friend template}}
};
}
namespace dr22 { // dr22: sup 481
template<typename dr22_T = dr22_T> struct X; // expected-error {{unknown type name 'dr22_T'}}
typedef int T;
template<typename T = T> struct Y;
}
namespace dr23 { // dr23: yes
template<typename T> void f(T, T); // expected-note {{candidate}}
template<typename T> void f(T, int); // expected-note {{candidate}}
void g() { f(0, 0); } // expected-error {{ambiguous}}
}
// dr24: na
namespace dr25 { // dr25: yes
struct A {
void f() throw(int);
};
void (A::*f)() throw (int);
void (A::*g)() throw () = f; // expected-error {{is not superset of source}}
void (A::*g2)() throw () = 0;
void (A::*h)() throw (int, char) = f;
void (A::*i)() throw () = &A::f; // expected-error {{is not superset of source}}
void (A::*i2)() throw () = 0;
void (A::*j)() throw (int, char) = &A::f;
void x() {
// FIXME: Don't produce the second error here.
g2 = f; // expected-error {{is not superset}} expected-error {{incompatible}}
h = f;
i2 = &A::f; // expected-error {{is not superset}} expected-error {{incompatible}}
j = &A::f;
}
}
namespace dr26 { // dr26: yes
struct A { A(A, const A & = A()); }; // expected-error {{must pass its first argument by reference}}
struct B {
B(); // expected-note {{candidate}}
B(const B &, B = B()); // expected-error {{no matching constructor}} expected-note {{candidate}} expected-note {{here}}
};
}
namespace dr27 { // dr27: yes
enum E { e } n;
E &m = true ? n : n;
}
// dr28: na
namespace dr29 { // dr29: 3.4
void dr29_f0(); // expected-note {{here}}
void g0() { void dr29_f0(); }
extern "C++" void g0_cxx() { void dr29_f0(); }
extern "C" void g0_c() { void dr29_f0(); } // expected-error {{different language linkage}}
extern "C" void dr29_f1(); // expected-note {{here}}
void g1() { void dr29_f1(); }
extern "C" void g1_c() { void dr29_f1(); }
extern "C++" void g1_cxx() { void dr29_f1(); } // expected-error {{different language linkage}}
void g2() { void dr29_f2(); } // expected-note {{here}}
extern "C" void dr29_f2(); // expected-error {{different language linkage}}
extern "C" void g3() { void dr29_f3(); } // expected-note {{here}}
extern "C++" void dr29_f3(); // expected-error {{different language linkage}}
extern "C++" void g4() { void dr29_f4(); } // expected-note {{here}}
extern "C" void dr29_f4(); // expected-error {{different language linkage}}
extern "C" void g5();
extern "C++" void dr29_f5();
void g5() {
void dr29_f5(); // ok, g5 is extern "C" but we're not inside the linkage-specification here.
}
extern "C++" void g6();
extern "C" void dr29_f6();
void g6() {
void dr29_f6(); // ok, g6 is extern "C" but we're not inside the linkage-specification here.
}
extern "C" void g7();
extern "C++" void dr29_f7(); // expected-note {{here}}
extern "C" void g7() {
void dr29_f7(); // expected-error {{different language linkage}}
}
extern "C++" void g8();
extern "C" void dr29_f8(); // expected-note {{here}}
extern "C++" void g8() {
void dr29_f8(); // expected-error {{different language linkage}}
}
}
namespace dr30 { // dr30: sup 468 c++11
struct A {
template<int> static int f();
} a, *p = &a;
int x = A::template f<0>();
int y = a.template f<0>();
int z = p->template f<0>();
#if __cplusplus < 201103L
// FIXME: It's not clear whether DR468 applies to C++98 too.
// expected-error@-5 {{'template' keyword outside of a template}}
// expected-error@-5 {{'template' keyword outside of a template}}
// expected-error@-5 {{'template' keyword outside of a template}}
#endif
}
namespace dr31 { // dr31: yes
class X {
private:
void operator delete(void*); // expected-note {{here}}
};
// We would call X::operator delete if X() threw (even though it can't,
// and even though we allocated the X using ::operator delete).
X *p = new X; // expected-error {{private}}
}
// dr32: na
namespace dr33 { // dr33: yes
namespace X { struct S; void f(void (*)(S)); } // expected-note {{candidate}}
namespace Y { struct T; void f(void (*)(T)); } // expected-note {{candidate}}
void g(X::S);
template<typename Z> Z g(Y::T);
void h() { f(&g); } // expected-error {{ambiguous}}
}
// dr34: na
// dr35: dup 178
// dr37: sup 475
namespace dr38 { // dr38: yes
template<typename T> struct X {};
template<typename T> X<T> operator+(X<T> a, X<T> b) { return a; }
template X<int> operator+<int>(X<int>, X<int>);
}
namespace dr39 { // dr39: no
namespace example1 {
struct A { int &f(int); };
struct B : A {
using A::f;
float &f(float);
} b;
int &r = b.f(0);
}
namespace example2 {
struct A {
int &x(int); // expected-note {{found}}
static int &y(int); // expected-note {{found}}
};
struct V {
int &z(int);
};
struct B : A, virtual V {
using A::x; // expected-note {{found}}
float &x(float);
using A::y; // expected-note {{found}}
static float &y(float);
using V::z;
float &z(float);
};
struct C : A, B, virtual V {} c; // expected-warning {{direct base 'dr39::example2::A' is inaccessible due to ambiguity:\n struct dr39::example2::C -> struct dr39::example2::A\n struct dr39::example2::C -> struct dr39::example2::B -> struct dr39::example2::A}}
int &x = c.x(0); // expected-error {{found in multiple base classes}}
// FIXME: This is valid, because we find the same static data member either way.
int &y = c.y(0); // expected-error {{found in multiple base classes}}
int &z = c.z(0);
}
namespace example3 {
struct A { static int f(); };
struct B : virtual A { using A::f; };
struct C : virtual A { using A::f; };
struct D : B, C {} d;
int k = d.f();
}
namespace example4 {
struct A { int n; }; // expected-note {{found}}
struct B : A {};
struct C : A {};
struct D : B, C { int f() { return n; } }; // expected-error {{found in multiple base-class}}
}
namespace PR5916 {
// FIXME: This is valid.
struct A { int n; }; // expected-note +{{found}}
struct B : A {};
struct C : A {};
struct D : B, C {};
int k = sizeof(D::n); // expected-error {{found in multiple base}} expected-error {{unknown type name}}
#if __cplusplus >= 201103L
decltype(D::n) n; // expected-error {{found in multiple base}}
#endif
}
}
// dr40: na
namespace dr41 { // dr41: yes
struct S f(S);
}
namespace dr42 { // dr42: yes
struct A { static const int k = 0; };
struct B : A { static const int k = A::k; };
}
// dr43: na
namespace dr44 { // dr44: yes
struct A {
template<int> void f();
template<> void f<0>(); // expected-error {{explicit specialization of 'f' in class scope}}
};
}
namespace dr45 { // dr45: yes
class A {
class B {};
class C : B {};
C c;
};
}
namespace dr46 { // dr46: yes
template<typename> struct A { template<typename> struct B {}; };
template template struct A<int>::B<int>; // expected-error {{expected unqualified-id}}
}
namespace dr47 { // dr47: sup 329
template<typename T> struct A {
friend void f() { T t; } // expected-error {{redefinition}} expected-note {{previous}}
};
A<int> a;
A<float> b; // expected-note {{instantiation of}}
void f();
void g() { f(); }
}
namespace dr48 { // dr48: yes
namespace {
struct S {
static const int m = 0;
static const int n = 0;
static const int o = 0;
};
}
int a = S::m;
// FIXME: We should produce a 'has internal linkage but is not defined'
// diagnostic for 'S::n'.
const int &b = S::n;
const int S::o;
const int &c = S::o;
}
namespace dr49 { // dr49: yes
template<int*> struct A {}; // expected-note 0-2{{here}}
int k;
#if __has_feature(cxx_constexpr)
constexpr
#endif
int *const p = &k; // expected-note 0-2{{here}}
A<&k> a;
A<p> b;
#if __cplusplus <= 201402L
// expected-error@-2 {{must have its address taken}}
#endif
#if __cplusplus < 201103L
// expected-error@-5 {{internal linkage}}
#endif
int *q = &k;
A<q> c;
#if __cplusplus < 201103L
// expected-error@-2 {{must have its address taken}}
#else
// expected-error@-4 {{constant expression}}
// expected-note@-5 {{read of non-constexpr}}
// expected-note@-7 {{declared here}}
#endif
}
namespace dr50 { // dr50: yes
struct X; // expected-note {{forward}}
extern X *p;
X *q = (X*)p;
X *r = static_cast<X*>(p);
X *s = const_cast<X*>(p);
X *t = reinterpret_cast<X*>(p);
X *u = dynamic_cast<X*>(p); // expected-error {{incomplete}}
}
namespace dr51 { // dr51: yes
struct A {};
struct B : A {};
struct S {
operator A&();
operator B&();
} s;
A &a = s;
}
namespace dr52 { // dr52: yes
struct A { int n; }; // expected-note {{here}}
struct B : private A {} b; // expected-note 2{{private}}
// FIXME: This first diagnostic is very strangely worded, and seems to be bogus.
int k = b.A::n; // expected-error {{'A' is a private member of 'dr52::A'}}
// expected-error@-1 {{cannot cast 'struct B' to its private base}}
}
namespace dr53 { // dr53: yes
int n = 0;
enum E { e } x = static_cast<E>(n);
}
namespace dr54 { // dr54: yes
struct A { int a; } a;
struct V { int v; } v;
struct B : private A, virtual V { int b; } b; // expected-note 6{{private here}}
A &sab = static_cast<A&>(b); // expected-error {{private base}}
A *spab = static_cast<A*>(&b); // expected-error {{private base}}
int A::*smab = static_cast<int A::*>(&B::b); // expected-error {{private base}}
B &sba = static_cast<B&>(a); // expected-error {{private base}}
B *spba = static_cast<B*>(&a); // expected-error {{private base}}
int B::*smba = static_cast<int B::*>(&A::a); // expected-error {{private base}}
V &svb = static_cast<V&>(b);
V *spvb = static_cast<V*>(&b);
int V::*smvb = static_cast<int V::*>(&B::b); // expected-error {{virtual base}}
B &sbv = static_cast<B&>(v); // expected-error {{virtual base}}
B *spbv = static_cast<B*>(&v); // expected-error {{virtual base}}
int B::*smbv = static_cast<int B::*>(&V::v); // expected-error {{virtual base}}
A &cab = (A&)(b);
A *cpab = (A*)(&b);
int A::*cmab = (int A::*)(&B::b);
B &cba = (B&)(a);
B *cpba = (B*)(&a);
int B::*cmba = (int B::*)(&A::a);
V &cvb = (V&)(b);
V *cpvb = (V*)(&b);
int V::*cmvb = (int V::*)(&B::b); // expected-error {{virtual base}}
B &cbv = (B&)(v); // expected-error {{virtual base}}
B *cpbv = (B*)(&v); // expected-error {{virtual base}}
int B::*cmbv = (int B::*)(&V::v); // expected-error {{virtual base}}
}
namespace dr55 { // dr55: yes
enum E { e = 5 };
int test[(e + 1 == 6) ? 1 : -1];
}
namespace dr56 { // dr56: yes
struct A {
typedef int T; // expected-note {{previous}}
typedef int T; // expected-error {{redefinition}}
};
struct B {
struct X;
typedef X X; // expected-note {{previous}}
typedef X X; // expected-error {{redefinition}}
};
}
namespace dr58 { // dr58: yes
// FIXME: Ideally, we should have a CodeGen test for this.
#if __cplusplus >= 201103L
enum E1 { E1_0 = 0, E1_1 = 1 };
enum E2 { E2_0 = 0, E2_m1 = -1 };
struct X { E1 e1 : 1; E2 e2 : 1; };
static_assert(X{E1_1, E2_m1}.e1 == 1, "");
static_assert(X{E1_1, E2_m1}.e2 == -1, "");
#endif
}
namespace dr59 { // dr59: yes
template<typename T> struct convert_to { operator T() const; };
struct A {}; // expected-note 2{{volatile qualifier}}
struct B : A {}; // expected-note 2{{volatile qualifier}}
#if __cplusplus >= 201103L // move constructors
// expected-note@-3 2{{volatile qualifier}}
// expected-note@-3 2{{volatile qualifier}}
#endif
A a1 = convert_to<A>();
A a2 = convert_to<A&>();
A a3 = convert_to<const A>();
A a4 = convert_to<const volatile A>(); // expected-error {{no viable}}
A a5 = convert_to<const volatile A&>(); // expected-error {{no viable}}
B b1 = convert_to<B>();
B b2 = convert_to<B&>();
B b3 = convert_to<const B>();
B b4 = convert_to<const volatile B>(); // expected-error {{no viable}}
B b5 = convert_to<const volatile B&>(); // expected-error {{no viable}}
int n1 = convert_to<int>();
int n2 = convert_to<int&>();
int n3 = convert_to<const int>();
int n4 = convert_to<const volatile int>();
int n5 = convert_to<const volatile int&>();
}
namespace dr60 { // dr60: yes
void f(int &);
int &f(...);
const int k = 0;
int &n = f(k);
}
namespace dr61 { // dr61: yes
struct X {
static void f();
} x;
struct Y {
static void f();
static void f(int);
} y;
// This is (presumably) valid, because x.f does not refer to an overloaded
// function name.
void (*p)() = &x.f;
void (*q)() = &y.f; // expected-error {{cannot create a non-constant pointer to member function}}
void (*r)() = y.f; // expected-error {{cannot create a non-constant pointer to member function}}
}
namespace dr62 { // dr62: yes
struct A {
struct { int n; } b;
};
template<typename T> struct X {};
template<typename T> T get() { return get<T>(); }
template<typename T> int take(T) { return 0; }
X<A> x1;
A a = get<A>();
typedef struct { } *NoNameForLinkagePtr;
#if __cplusplus < 201103L
// expected-note@-2 5{{here}}
#endif
NoNameForLinkagePtr noNameForLinkagePtr;
struct Danger {
NoNameForLinkagePtr p;
};
X<NoNameForLinkagePtr> x2;
X<const NoNameForLinkagePtr> x3;
NoNameForLinkagePtr p1 = get<NoNameForLinkagePtr>();
NoNameForLinkagePtr p2 = get<const NoNameForLinkagePtr>();
int n1 = take(noNameForLinkagePtr);
#if __cplusplus < 201103L
// expected-error@-6 {{uses unnamed type}}
// expected-error@-6 {{uses unnamed type}}
// expected-error@-6 {{uses unnamed type}}
// expected-error@-6 {{uses unnamed type}}
// expected-error@-6 {{uses unnamed type}}
#endif
X<Danger> x4;
void f() {
struct NoLinkage {};
X<NoLinkage> a;
X<const NoLinkage> b;
get<NoLinkage>();
get<const NoLinkage>();
X<void (*)(NoLinkage A::*)> c;
X<int NoLinkage::*> d;
#if __cplusplus < 201103L
// expected-error@-7 {{uses local type}}
// expected-error@-7 {{uses local type}}
// expected-error@-7 {{uses local type}}
// expected-error@-7 {{uses local type}}
// expected-error@-7 {{uses local type}}
// expected-error@-7 {{uses local type}}
#endif
}
}
namespace dr63 { // dr63: yes
template<typename T> struct S { typename T::error e; };
extern S<int> *p;
void *q = p;
}
namespace dr64 { // dr64: yes
template<class T> void f(T);
template<class T> void f(T*);
template<> void f(int*);
template<> void f<int>(int*);
template<> void f(int);
}
// dr65: na
namespace dr66 { // dr66: no
namespace X {
int f(int n); // expected-note 2{{candidate}}
}
using X::f;
namespace X {
int f(int n = 0);
int f(int, int);
}
// FIXME: The first two calls here should be accepted.
int a = f(); // expected-error {{no matching function}}
int b = f(1);
int c = f(1, 2); // expected-error {{no matching function}}
}
// dr67: na
namespace dr68 { // dr68: yes
template<typename T> struct X {};
struct ::dr68::X<int> x1;
struct ::dr68::template X<int> x2;
#if __cplusplus < 201103L
// expected-error@-2 {{'template' keyword outside of a template}}
#endif
struct Y {
friend struct X<int>;
friend struct ::dr68::X<char>;
friend struct ::dr68::template X<double>;
#if __cplusplus < 201103L
// expected-error@-2 {{'template' keyword outside of a template}}
#endif
};
template<typename>
struct Z {
friend struct ::dr68::template X<double>;
friend typename ::dr68::X<double>;
#if __cplusplus < 201103L
// expected-error@-2 {{C++11 extension}}
#endif
};
}
namespace dr69 { // dr69: yes
template<typename T> static void f() {}
// FIXME: Should we warn here?
inline void g() { f<int>(); }
// FIXME: This should be rejected, per [temp.explicit]p11.
extern template void f<char>();
#if __cplusplus < 201103L
// expected-error@-2 {{C++11 extension}}
#endif
template<void(*)()> struct Q {};
Q<&f<int> > q;
#if __cplusplus < 201103L
// expected-error@-2 {{internal linkage}} expected-note@-11 {{here}}
#endif
}
namespace dr70 { // dr70: yes
template<int> struct A {};
template<int I, int J> int f(int (&)[I + J], A<I>, A<J>);
int arr[7];
int k = f(arr, A<3>(), A<4>());
}
// dr71: na
// dr72: dup 69
#if __cplusplus >= 201103L
namespace dr73 { // dr73: no
// The resolution to dr73 is unworkable. Consider:
int a, b;
static_assert(&a + 1 != &b, ""); // expected-error {{not an integral constant expression}}
}
#endif
namespace dr74 { // dr74: yes
enum E { k = 5 };
int (*p)[k] = new int[k][k];
}
namespace dr75 { // dr75: yes
struct S {
static int n = 0; // expected-error {{non-const}}
};
}
namespace dr76 { // dr76: yes
const volatile int n = 1;
int arr[n]; // expected-error +{{variable length array}}
}
namespace dr77 { // dr77: yes
struct A {
struct B {};
friend struct B;
};
}
namespace dr78 { // dr78: sup ????
// Under DR78, this is valid, because 'k' has static storage duration, so is
// zero-initialized.
const int k; // expected-error {{default initialization of an object of const}}
}
// dr79: na
namespace dr80 { // dr80: yes
struct A {
int A;
};
struct B {
static int B; // expected-error {{same name as its class}}
};
struct C {
int C; // expected-note {{hidden by}}
// FIXME: These diagnostics aren't very good.
C(); // expected-error {{must use 'struct' tag to refer to}} expected-error {{expected member name}}
};
struct D {
D();
int D; // expected-error {{same name as its class}}
};
}
// dr81: na
// dr82: dup 48
namespace dr83 { // dr83: yes
int &f(const char*);
char &f(char *);
int &k = f("foo");
}
namespace dr84 { // dr84: yes
struct B;
struct A { operator B() const; };
struct C {};
struct B {
B(B&); // expected-note {{candidate}}
B(C);
operator C() const;
};
A a;
// Cannot use B(C) / operator C() pair to construct the B from the B temporary
// here.
B b = a; // expected-error {{no viable}}
}
namespace dr85 { // dr85: yes
struct A {
struct B;
struct B {}; // expected-note{{previous declaration is here}}
struct B; // expected-error{{class member cannot be redeclared}}
union U;
union U {}; // expected-note{{previous declaration is here}}
union U; // expected-error{{class member cannot be redeclared}}
#if __cplusplus >= 201103L
enum E1 : int;
enum E1 : int { e1 }; // expected-note{{previous declaration is here}}
enum E1 : int; // expected-error{{class member cannot be redeclared}}
enum class E2;
enum class E2 { e2 }; // expected-note{{previous declaration is here}}
enum class E2; // expected-error{{class member cannot be redeclared}}
#endif
};
template <typename T>
struct C {
struct B {}; // expected-note{{previous declaration is here}}
struct B; // expected-error{{class member cannot be redeclared}}
};
}
// dr86: dup 446
namespace dr87 { // dr87: no
template<typename T> struct X {};
// FIXME: This is invalid.
X<void() throw()> x;
// ... but this is valid.
X<void(void() throw())> y;
}
namespace dr88 { // dr88: yes
template<typename T> struct S {
static const int a = 1; // expected-note {{previous}}
static const int b;
};
template<> const int S<int>::a = 4; // expected-error {{already has an initializer}}
template<> const int S<int>::b = 4;
}
// dr89: na
namespace dr90 { // dr90: yes
struct A {
template<typename T> friend void dr90_f(T);
};
struct B : A {
template<typename T> friend void dr90_g(T);
struct C {};
union D {};
};
struct E : B {};
struct F : B::C {};
void test() {
dr90_f(A());
dr90_f(B());
dr90_f(B::C()); // expected-error {{undeclared identifier}}
dr90_f(B::D()); // expected-error {{undeclared identifier}}
dr90_f(E());
dr90_f(F()); // expected-error {{undeclared identifier}}
dr90_g(A()); // expected-error {{undeclared identifier}}
dr90_g(B());
dr90_g(B::C());
dr90_g(B::D());
dr90_g(E());
dr90_g(F()); // expected-error {{undeclared identifier}}
}
}
namespace dr91 { // dr91: yes
union U { friend int f(U); };
int k = f(U());
}
namespace dr92 { // FIXME: Issue is still open.
void f() throw(int, float);
void (*p)() throw(int) = &f; // expected-error {{target exception specification is not superset of source}}
void (*q)() throw(int);
void (**pp)() throw() = &q; // expected-error {{exception specifications are not allowed}}
void g(void() throw());
void h() {
g(f); // expected-error {{is not superset}}
g(q); // expected-error {{is not superset}}
}
// Prior to C++17, this is OK because the exception specification is not
// considered in this context. In C++17, we *do* perform an implicit
// conversion (which performs initialization), but we convert to the type of
// the template parameter, which does not include the exception specification.
template<void() throw()> struct X {};
X<&f> xp; // ok
}
// dr93: na
namespace dr94 { // dr94: yes
struct A { static const int n = 5; };
int arr[A::n];
}
namespace dr95 { // dr95: yes
struct A;
struct B;
namespace N {
class C {
friend struct A;
friend struct B;
static void f(); // expected-note {{here}}
};
struct A *p; // dr95::A, not dr95::N::A.
}
A *q = N::p; // ok, same type
struct B { void f() { N::C::f(); } }; // expected-error {{private}}
}
namespace dr96 { // dr96: no
struct A {
void f(int);
template<typename T> int f(T);
template<typename T> struct S {};
} a;
template<template<typename> class X> struct B {};
template<typename T>
void test() {
int k1 = a.template f<int>(0);
// FIXME: This is ill-formed, because 'f' is not a template-id and does not
// name a class template.
// FIXME: What about alias templates?
int k2 = a.template f(1);
A::template S<int> s;
B<A::template S> b;
}
}
namespace dr97 { // dr97: yes
struct A {
static const int a = false;
static const int b = !a;
};
}
namespace dr98 { // dr98: yes
void test(int n) {
switch (n) {
try { // expected-note 2{{bypasses}}
case 0: // expected-error {{cannot jump}}
x:
throw n;
} catch (...) { // expected-note 2{{bypasses}}
case 1: // expected-error {{cannot jump}}
y:
throw n;
}
case 2:
goto x; // expected-error {{cannot jump}}
case 3:
goto y; // expected-error {{cannot jump}}
}
}
}
namespace dr99 { // dr99: sup 214
template<typename T> void f(T&);
template<typename T> int &f(const T&);
const int n = 0;
int &r = f(n);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr10xx.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// expected-no-diagnostics
namespace std {
__extension__ typedef __SIZE_TYPE__ size_t;
template<typename T> struct initializer_list {
const T *p; size_t n;
initializer_list(const T *p, size_t n);
};
}
namespace dr1048 { // dr1048: 3.6
struct A {};
const A f();
A g();
typedef const A CA;
#if __cplusplus >= 201103L
// ok: we deduce non-const A in each case.
A &&a = [] (int n) {
while (1) switch (n) {
case 0: return f();
case 1: return g();
case 2: return A();
case 3: return CA();
}
} (0);
#endif
}
namespace dr1070 { // dr1070: 3.5
#if __cplusplus >= 201103L
struct A {
A(std::initializer_list<int>);
};
struct B {
int i;
A a;
};
B b = {1};
struct C {
std::initializer_list<int> a;
B b;
std::initializer_list<double> c;
};
C c = {};
#endif
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr18xx.cpp
|
// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
#if __cplusplus < 201103L
// expected-no-diagnostics
#endif
void dr1891() { // dr1891: 3.6
#if __cplusplus >= 201103L
int n;
auto a = []{}; // expected-note 2{{candidate}}
auto b = [=]{ return n; }; // expected-note 2{{candidate}}
typedef decltype(a) A;
typedef decltype(b) B;
static_assert(!__has_trivial_constructor(A), "");
static_assert(!__has_trivial_constructor(B), "");
A x; // expected-error {{no matching constructor}}
B y; // expected-error {{no matching constructor}}
#endif
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr1748.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s
// RUN: %clang_cc1 -std=c++1z %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s
// dr1748: 3.7
// FIXME: __SIZE_TYPE__ expands to 'long long' on some targets.
__extension__ typedef __SIZE_TYPE__ size_t;
void *operator new(size_t, void *);
void *operator new[](size_t, void *);
struct X { X(); };
// The reserved placement allocation functions get inlined
// even if we can't see their definitions. They do not
// perform a null check.
// CHECK-LABEL: define {{.*}} @_Z1fPv(
// CHECK-NOT: call
// CHECK-NOT: icmp{{.*}} null
// CHECK-NOT: br i1
// CHECK: call void @_ZN1XC1Ev(
// CHECK: }
X *f(void *p) { return new (p) X; }
// CHECK-LABEL: define {{.*}} @_Z1gPv(
// CHECK-NOT: call
// CHECK-NOT: icmp{{.*}} null
// CHECK-NOT: br i1
// CHECK: call void @_ZN1XC1Ev(
// CHECK: br i1
// CHECK: }
X *g(void *p) { return new (p) X[5]; }
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr4xx.cpp
|
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// FIXME: __SIZE_TYPE__ expands to 'long long' on some targets.
__extension__ typedef __SIZE_TYPE__ size_t;
namespace std { struct type_info; }
namespace dr400 { // dr400: yes
struct A { int a; struct a {}; }; // expected-note 2{{conflicting}} expected-note {{ambiguous}}
struct B { int a; struct a {}; }; // expected-note 2{{target}} expected-note {{ambiguous}}
struct C : A, B { using A::a; struct a b; };
struct D : A, B { using A::a; using B::a; struct a b; }; // expected-error 2{{conflicts}}
struct E : A, B { struct a b; }; // expected-error {{found in multiple base classes}}
}
namespace dr401 { // dr401: yes
template<class T, class U = typename T::type> class A : public T {}; // expected-error {{protected}} expected-error 2{{private}}
class B {
protected:
typedef int type; // expected-note {{protected}}
};
class C {
typedef int type; // expected-note {{private}}
friend class A<C>; // expected-note {{default argument}}
};
class D {
typedef int type; // expected-note {{private}}
friend class A<D, int>;
};
A<B> *b; // expected-note {{default argument}}
// FIXME: We're missing the "in instantiation of" note for the default
// argument here.
A<D> *d;
struct E {
template<class T, class U = typename T::type> class A : public T {};
};
class F {
typedef int type;
friend class E;
};
E::A<F> eaf; // ok, default argument is in befriended context
// FIXME: Why do we get different diagnostics in C++11 onwards here? We seem
// to not treat the default template argument as a SFINAE context in C++98.
template<class T, class U = typename T::type> void f(T) {}
void g(B b) { f(b); }
#if __cplusplus < 201103L
// expected-error@-3 0-1{{extension}} expected-error@-3 {{protected}} expected-note@-3 {{instantiation}}
// expected-note@-3 {{substituting}}
#else
// expected-error@-5 {{no matching}} expected-note@-6 {{protected}}
#endif
}
namespace dr403 { // dr403: yes
namespace A {
struct S {};
int f(void*);
}
template<typename T> struct X {};
typedef struct X<A::S>::X XS;
XS *p;
int k = f(p); // ok, finds A::f, even though type XS is a typedef-name
// referring to an elaborated-type-specifier naming a
// injected-class-name, which is about as far from a
// template-id as we can make it.
}
// dr404: na
// (NB: also sup 594)
namespace dr406 { // dr406: yes
typedef struct {
static int n; // expected-error {{static data member 'n' not allowed in anonymous struct}}
} A;
}
namespace dr407 { // dr407: no
struct S;
typedef struct S S;
void f() {
struct S *p;
{
typedef struct S S; // expected-note {{here}}
struct S *p; // expected-error {{refers to a typedef}}
}
}
struct S {};
namespace UsingDir {
namespace A {
struct S {}; // expected-note {{found}}
}
namespace B {
typedef int S; // expected-note {{found}}
}
namespace C {
using namespace A;
using namespace B;
struct S s; // expected-error {{ambiguous}}
}
namespace D {
// FIXME: This is valid.
using A::S;
typedef struct S S; // expected-note {{here}}
struct S s; // expected-error {{refers to a typedef}}
}
namespace E {
// FIXME: The standard doesn't say whether this is valid.
typedef A::S S;
using A::S;
struct S s;
}
namespace F {
typedef A::S S; // expected-note {{here}}
}
// FIXME: The standard doesn't say what to do in these cases, but
// our behavior should not depend on the order of the using-directives.
namespace G {
using namespace A;
using namespace F;
struct S s;
}
namespace H {
using namespace F;
using namespace A;
struct S s; // expected-error {{refers to a typedef}}
}
}
}
namespace dr408 { // dr408: 3.4
template<int N> void g() { int arr[N != 1 ? 1 : -1]; }
template<> void g<2>() { }
template<typename T> struct S {
static int i[];
void f();
};
template<typename T> int S<T>::i[] = { 1 };
template<typename T> void S<T>::f() {
g<sizeof (i) / sizeof (int)>();
}
template<> int S<int>::i[] = { 1, 2 };
template void S<int>::f(); // uses g<2>(), not g<1>().
template<typename T> struct R {
static int arr[];
void f();
};
template<typename T> int R<T>::arr[1];
template<typename T> void R<T>::f() {
int arr[sizeof(arr) != sizeof(int) ? 1 : -1];
}
template<> int R<int>::arr[2];
template void R<int>::f();
}
namespace dr409 { // dr409: yes
template<typename T> struct A {
typedef int B;
B b1;
A::B b2;
A<T>::B b3;
A<T*>::B b4; // expected-error {{missing 'typename'}}
};
}
namespace dr410 { // dr410: no
template<class T> void f(T);
void g(int);
namespace M {
template<class T> void h(T);
template<class T> void i(T);
struct A {
friend void f<>(int);
friend void h<>(int);
friend void g(int);
template<class T> void i(T);
friend void i<>(int);
private:
static void z(); // expected-note {{private}}
};
template<> void h(int) { A::z(); }
// FIXME: This should be ill-formed. The member A::i<> is befriended,
// not this function.
template<> void i(int) { A::z(); }
}
template<> void f(int) { M::A::z(); }
void g(int) { M::A::z(); } // expected-error {{private}}
}
// dr412 is in its own file.
namespace dr413 { // dr413: yes
struct S {
int a;
int : 17;
int b;
};
S s = { 1, 2, 3 }; // expected-error {{excess elements}}
struct E {};
struct T { // expected-note {{here}}
int a;
E e;
int b;
};
T t1 = { 1, {}, 2 };
T t2 = { 1, 2 }; // expected-error {{aggregate with no elements requires explicit braces}}
}
namespace dr414 { // dr414: dup 305
struct X {};
void f() {
X x;
struct X {};
x.~X();
}
}
namespace dr415 { // dr415: yes
template<typename T> void f(T, ...) { T::error; }
void f(int, int);
void g() { f(0, 0); } // ok
}
namespace dr416 { // dr416: yes
extern struct A a;
int &operator+(const A&, const A&);
int &k = a + a;
struct A { float &operator+(A&); };
float &f = a + a;
}
namespace dr417 { // dr417: no
struct A;
struct dr417::A {}; // expected-warning {{extra qualification}}
struct B { struct X; };
struct C : B {};
struct C::X {}; // expected-error {{no struct named 'X' in 'dr417::C'}}
struct B::X { struct Y; };
struct C::X::Y {}; // ok!
namespace N {
struct D;
struct E;
struct F;
struct H;
}
// FIXME: This is ill-formed.
using N::D;
struct dr417::D {}; // expected-warning {{extra qualification}}
using namespace N;
struct dr417::E {}; // expected-warning {{extra qualification}} expected-error {{no struct named 'E'}}
struct N::F {};
struct G;
using N::H;
namespace M {
struct dr417::G {}; // expected-error {{namespace 'M' does not enclose}}
struct dr417::H {}; // expected-error {{namespace 'M' does not enclose}}
}
}
namespace dr420 { // dr420: yes
template<typename T> struct ptr {
T *operator->() const;
T &operator*() const;
};
template<typename T, typename P> void test(P p) {
p->~T();
p->T::~T();
(*p).~T();
(*p).T::~T();
}
struct X {};
template void test<int>(int*);
template void test<int>(ptr<int>);
template void test<X>(X*);
template void test<X>(ptr<X>);
template<typename T>
void test2(T p) {
p->template Y<int>::~Y<int>();
p->~Y<int>();
// FIXME: This is ill-formed, but this diagnostic is terrible. We should
// reject this in the parser.
p->template ~Y<int>(); // expected-error 2{{no member named '~typename Y<int>'}}
}
template<typename T> struct Y {};
template void test2(Y<int>*); // expected-note {{instantiation}}
template void test2(ptr<Y<int> >); // expected-note {{instantiation}}
void test3(int *p, ptr<int> q) {
typedef int Int;
p->~Int();
q->~Int();
p->Int::~Int();
q->Int::~Int();
}
#if __cplusplus >= 201103L
template<typename T> using id = T;
struct A { template<typename T> using id = T; };
void test4(int *p, ptr<int> q) {
p->~id<int>();
q->~id<int>();
p->id<int>::~id<int>();
q->id<int>::~id<int>();
p->template id<int>::~id<int>(); // expected-error {{expected unqualified-id}}
q->template id<int>::~id<int>(); // expected-error {{expected unqualified-id}}
p->A::template id<int>::~id<int>();
q->A::template id<int>::~id<int>();
}
#endif
}
namespace dr421 { // dr421: yes
struct X { X(); int n; int &r; };
int *p = &X().n; // expected-error {{taking the address of a temporary}}
int *q = &X().r;
}
namespace dr422 { // dr422: yes
template<typename T, typename U> void f() {
typedef T type; // expected-note {{prev}}
typedef U type; // expected-error {{redef}}
}
template void f<int, int>();
template void f<int, char>(); // expected-note {{instantiation}}
}
namespace dr423 { // dr423: yes
template<typename T> struct X { operator T&(); };
void f(X<int> x) { x += 1; }
}
namespace dr424 { // dr424: yes
struct A {
typedef int N; // expected-note {{previous}}
typedef int N; // expected-error {{redefinition}}
struct X;
typedef X X; // expected-note {{previous}}
struct X {};
struct X *p;
struct A::X *q;
X *r;
typedef X X; // expected-error {{redefinition}}
};
struct B {
typedef int N;
};
struct C : B {
typedef int N; // expected-note {{previous}}
typedef int N; // expected-error {{redefinition}}
};
}
namespace dr425 { // dr425: yes
struct A { template<typename T> operator T() const; } a;
float f = 1.0f * a; // expected-error {{ambiguous}} expected-note 5+{{built-in candidate}}
template<typename T> struct is_float;
template<> struct is_float<float> { typedef void type; };
struct B {
template<typename T, typename U = typename is_float<T>::type> operator T() const; // expected-error 0-1{{extension}}
} b;
float g = 1.0f * b; // ok
}
namespace dr427 { // dr427: yes
struct B {};
struct D : public B {
D(B &) = delete; // expected-error 0-1{{extension}} expected-note {{deleted}}
};
extern D d1;
B &b = d1;
const D &d2 = static_cast<const D&>(b);
const D &d3 = (const D&)b;
const D &d4(b); // expected-error {{deleted}}
}
namespace dr428 { // dr428: yes
template<typename T> T make();
extern struct X x; // expected-note 5{{forward declaration}}
void f() {
throw void(); // expected-error {{cannot throw}}
throw make<void*>();
throw make<const volatile void*>();
throw x; // expected-error {{cannot throw}}
throw make<X&>(); // expected-error {{cannot throw}}
throw make<X*>(); // expected-error {{cannot throw}}
throw make<const volatile X&>(); // expected-error {{cannot throw}}
throw make<const volatile X*>(); // expected-error {{cannot throw}}
}
}
namespace dr429 { // dr429: yes c++11
// FIXME: This rule is obviously intended to apply to C++98 as well.
struct A {
static void *operator new(size_t, size_t);
static void operator delete(void*, size_t);
} *a = new (0) A;
#if __cplusplus >= 201103L
// expected-error@-2 {{'new' expression with placement arguments refers to non-placement 'operator delete'}}
// expected-note@-4 {{here}}
#endif
struct B {
static void *operator new(size_t, size_t);
static void operator delete(void*);
static void operator delete(void*, size_t);
} *b = new (0) B; // ok, second delete is not a non-placement deallocation function
}
namespace dr430 { // dr430: yes c++11
// resolved by n2239
// FIXME: This should apply in C++98 too.
void f(int n) {
int a[] = { n++, n++, n++ };
#if __cplusplus < 201103L
// expected-warning@-2 {{multiple unsequenced modifications to 'n'}}
#endif
}
}
namespace dr431 { // dr431: yes
struct A {
template<typename T> T *get();
template<typename T> struct B {
template<typename U> U *get();
};
};
template<typename T> void f(A a) {
a.get<A>()->get<T>();
a.get<T>()
->get<T>(); // expected-error {{use 'template'}}
a.get<T>()->template get<T>();
a.A::get<T>();
A::B<int> *b = a.get<A::B<int> >();
b->get<int>();
b->A::B<int>::get<int>();
b->A::B<int>::get<T>();
b->A::B<T>::get<int>(); // expected-error {{use 'template'}}
b->A::B<T>::template get<int>();
b->A::B<T>::get<T>(); // expected-error {{use 'template'}}
b->A::B<T>::template get<T>();
A::B<T> *c = a.get<A::B<T> >();
c->get<int>(); // expected-error {{use 'template'}}
c->template get<int>();
}
}
namespace dr432 { // dr432: yes
template<typename T> struct A {};
template<typename T> struct B : A<B> {}; // expected-error {{requires template arguments}} expected-note {{declared}}
template<typename T> struct C : A<C<T> > {};
#if __cplusplus >= 201103L
template<typename T> struct D : decltype(A<D>()) {}; // expected-error {{requires template arguments}} expected-note {{declared}}
#endif
}
namespace dr433 { // dr433: yes
template<class T> struct S {
void f(union U*);
};
U *p;
template<class T> void S<T>::f(union U*) {}
S<int> s;
}
namespace dr434 { // dr434: yes
void f() {
const int ci = 0;
int *pi = 0;
const int *&rpci = pi; // expected-error {{cannot bind}}
rpci = &ci;
*pi = 1;
}
}
// dr435: na
namespace dr436 { // dr436: yes
enum E { f }; // expected-note {{previous}}
void f(); // expected-error {{redefinition}}
}
namespace dr437 { // dr437: sup 1308
// This is superseded by 1308, which is in turn superseded by 1330,
// which restores this rule.
template<typename U> struct T : U {};
struct S {
void f() throw(S);
void g() throw(T<S>);
struct U;
void h() throw(U);
struct U {};
};
}
// dr438 FIXME write a codegen test
// dr439 FIXME write a codegen test
// dr441 FIXME write a codegen test
// dr442: sup 348
// dr443: na
namespace dr444 { // dr444: yes
struct D;
struct B { // expected-note {{candidate is the implicit copy}} expected-note 0-1 {{implicit move}}
D &operator=(D &) = delete; // expected-error 0-1{{extension}} expected-note {{deleted}}
};
struct D : B { // expected-note {{candidate is the implicit}} expected-note 0-1 {{implicit move}}
using B::operator=;
} extern d;
void f() {
d = d; // expected-error {{deleted}}
}
}
namespace dr445 { // dr445: yes
class A { void f(); }; // expected-note {{private}}
struct B {
friend void A::f(); // expected-error {{private}}
};
}
namespace dr446 { // dr446: yes
struct C;
struct A {
A();
A(const A&) = delete; // expected-error 0-1{{extension}} expected-note +{{deleted}}
A(const C&);
};
struct C : A {};
void f(A a, bool b, C c) {
void(b ? a : a);
b ? A() : a; // expected-error {{deleted}}
b ? a : A(); // expected-error {{deleted}}
b ? A() : A(); // expected-error {{deleted}}
void(b ? a : c);
b ? a : C(); // expected-error {{deleted}}
b ? c : A(); // expected-error {{deleted}}
b ? A() : C(); // expected-error {{deleted}}
}
}
namespace dr447 { // dr447: yes
struct A { int n; int a[4]; };
template<int> struct U {
typedef int type;
template<typename V> static void h();
};
template<typename T> U<sizeof(T)> g(T);
template<typename T, int N> void f(int n) {
// ok, not type dependent
g(__builtin_offsetof(A, n)).h<int>();
g(__builtin_offsetof(T, n)).h<int>();
// value dependent if first argument is a dependent type
U<__builtin_offsetof(A, n)>::type a;
U<__builtin_offsetof(T, n)>::type b; // expected-error +{{}} expected-warning 0+{{}}
// as an extension, we allow the member-designator to include array indices
g(__builtin_offsetof(A, a[0])).h<int>(); // expected-error {{extension}}
g(__builtin_offsetof(A, a[N])).h<int>(); // expected-error {{extension}}
U<__builtin_offsetof(A, a[0])>::type c; // expected-error {{extension}}
U<__builtin_offsetof(A, a[N])>::type d; // expected-error {{extension}} expected-error +{{}} expected-warning 0+{{}}
}
}
namespace dr448 { // dr448: yes
template<typename T = int> void f(int); // expected-error 0-1{{extension}} expected-note {{no known conversion}}
template<typename T> void g(T t) {
f<T>(t); // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}}
dr448::f(t); // expected-error {{no matching function}}
}
template<typename T> void f(T); // expected-note {{should be declared prior to the call site}}
namespace HideFromADL { struct X {}; }
template void g(int); // ok
template void g(HideFromADL::X); // expected-note {{instantiation of}}
}
// dr449: na
namespace dr450 { // dr450: yes
typedef int A[3];
void f1(const A &);
void f2(A &); // expected-note +{{not viable}}
struct S { A n; };
void g() {
f1(S().n);
f2(S().n); // expected-error {{no match}}}
}
#if __cplusplus >= 201103L
void h() {
f1(A{});
f2(A{}); // expected-error {{no match}}
}
#endif
}
namespace dr451 { // dr451: yes
const int a = 1 / 0; // expected-warning {{undefined}}
const int b = 1 / 0; // expected-warning {{undefined}}
int arr[b]; // expected-error +{{variable length arr}}
}
namespace dr452 { // dr452: yes
struct A {
int a, b, c;
A *p;
int f();
A() : a(f()), b(this->f() + a), c(this->a), p(this) {}
};
}
// dr454 FIXME write a codegen test
namespace dr456 { // dr456: yes
// sup 903 c++11
const int null = 0;
void *p = null;
#if __cplusplus >= 201103L
// expected-error@-2 {{cannot initialize}}
#else
// expected-warning@-4 {{null}}
#endif
const bool f = false;
void *q = f;
#if __cplusplus >= 201103L
// expected-error@-2 {{cannot initialize}}
#else
// expected-warning@-4 {{null}}
#endif
}
namespace dr457 { // dr457: yes
const int a = 1;
const volatile int b = 1;
int ax[a];
int bx[b]; // expected-error +{{variable length array}}
enum E {
ea = a,
eb = b // expected-error {{not an integral constant}} expected-note {{read of volatile-qualified}}
};
}
namespace dr458 { // dr458: no
struct A {
int T;
int f();
template<typename> int g();
};
template<typename> struct B : A {
int f();
template<typename> int g();
template<typename> int h();
};
int A::f() {
return T;
}
template<typename T>
int A::g() {
return T; // FIXME: this is invalid, it finds the template parameter
}
template<typename T>
int B<T>::f() {
return T;
}
template<typename T> template<typename U>
int B<T>::g() {
return T;
}
template<typename U> template<typename T>
int B<U>::h() {
return T; // FIXME: this is invalid, it finds the template parameter
}
}
namespace dr460 { // dr460: yes
namespace X { namespace Q { int n; } }
namespace Y {
using X; // expected-error {{requires a qualified name}}
using dr460::X; // expected-error {{cannot refer to namespace}}
using X::Q; // expected-error {{cannot refer to namespace}}
}
}
// dr461: na
// dr462 FIXME write a codegen test
// dr463: na
// dr464: na
// dr465: na
namespace dr466 { // dr466: no
typedef int I;
typedef const int CI;
typedef volatile int VI;
void f(int *a, CI *b, VI *c) {
a->~I();
a->~CI();
a->~VI();
a->I::~I();
a->CI::~CI();
a->VI::~VI();
a->CI::~VI(); // FIXME: This is invalid; CI and VI are not the same scalar type.
b->~I();
b->~CI();
b->~VI();
b->I::~I();
b->CI::~CI();
b->VI::~VI();
c->~I();
c->~CI();
c->~VI();
c->I::~I();
c->CI::~CI();
c->VI::~VI();
}
}
namespace dr467 { // dr467: yes
int stuff();
int f() {
static bool done;
if (done)
goto later;
static int k = stuff();
done = true;
later:
return k;
}
int g() {
goto later; // expected-error {{cannot jump}}
int k = stuff(); // expected-note {{bypasses variable initialization}}
later:
return k;
}
}
namespace dr468 { // dr468: yes c++11
// FIXME: Should we allow this in C++98 too?
template<typename> struct A {
template<typename> struct B {
static int C;
};
};
int k = dr468::template A<int>::template B<char>::C;
#if __cplusplus < 201103L
// expected-error@-2 2{{'template' keyword outside of a template}}
#endif
}
namespace dr469 { // dr469: no
// FIXME: The core issue here didn't really answer the question. We don't
// deduce 'const T' from a function or reference type in a class template...
template<typename T> struct X; // expected-note 2{{here}}
template<typename T> struct X<const T> {};
X<int&> x; // expected-error {{undefined}}
X<int()> y; // expected-error {{undefined}}
// ... but we do in a function template. GCC and EDG fail deduction of 'f'
// and the second 'h'.
template<typename T> void f(const T *);
template<typename T> void g(T *, const T * = 0);
template<typename T> void h(T *) { T::error; }
template<typename T> void h(const T *);
void i() {
f(&i);
g(&i);
h(&i);
}
}
namespace dr470 { // dr470: yes
template<typename T> struct A {
struct B {};
};
template<typename T> struct C {
};
template struct A<int>; // expected-note {{previous}}
template struct A<int>::B; // expected-error {{duplicate explicit instantiation}}
// ok, instantiating C<char> doesn't instantiate base class members.
template struct A<char>;
template struct C<char>;
}
namespace dr471 { // dr471: yes
struct A { int n; };
struct B : private virtual A {};
struct C : protected virtual A {};
struct D : B, C { int f() { return n; } };
struct E : private virtual A {
using A::n;
};
struct F : E, B { int f() { return n; } };
struct G : virtual A {
private:
using A::n; // expected-note {{here}}
};
struct H : B, G { int f() { return n; } }; // expected-error {{private}}
}
namespace dr474 { // dr474: yes
namespace N {
struct S {
void f();
};
}
void N::S::f() {
void g(); // expected-note {{previous}}
}
int g();
namespace N {
int g(); // expected-error {{cannot be overloaded}}
}
}
// dr475 FIXME write a codegen test
namespace dr477 { // dr477: 3.5
struct A {
explicit A();
virtual void f();
};
struct B {
friend explicit A::A(); // expected-error {{'explicit' is invalid in friend declarations}}
friend virtual void A::f(); // expected-error {{'virtual' is invalid in friend declarations}}
};
explicit A::A() {} // expected-error {{can only be specified inside the class definition}}
virtual void A::f() {} // expected-error {{can only be specified inside the class definition}}
}
namespace dr478 { // dr478: yes
struct A { virtual void f() = 0; }; // expected-note {{unimplemented}}
void f(A *a);
void f(A a[10]); // expected-error {{array of abstract class type}}
}
namespace dr479 { // dr479: yes
struct S {
S();
private:
S(const S&); // expected-note +{{here}}
~S(); // expected-note +{{here}}
};
void f() {
throw S();
// expected-error@-1 {{temporary of type 'dr479::S' has private destructor}}
// expected-error@-2 {{calling a private constructor}}
// expected-error@-3 {{exception object of type 'dr479::S' has private destructor}}
#if __cplusplus < 201103L
// expected-error@-5 {{C++98 requires an accessible copy constructor}}
#endif
}
void g() {
S s; // expected-error {{private destructor}}}
throw s;
// expected-error@-1 {{calling a private constructor}}
// expected-error@-2 {{exception object of type 'dr479::S' has private destructor}}
}
void h() {
try {
f();
g();
} catch (S s) {
// expected-error@-1 {{calling a private constructor}}
// expected-error@-2 {{variable of type 'dr479::S' has private destructor}}
}
}
}
namespace dr480 { // dr480: yes
struct A { int n; };
struct B : A {};
struct C : virtual B {};
struct D : C {};
int A::*a = &A::n;
int D::*b = a; // expected-error {{virtual base}}
extern int D::*c;
int A::*d = static_cast<int A::*>(c); // expected-error {{virtual base}}
D *e;
A *f = e;
D *g = static_cast<D*>(f); // expected-error {{virtual base}}
extern D &i;
A &j = i;
D &k = static_cast<D&>(j); // expected-error {{virtual base}}
}
namespace dr481 { // dr481: yes
template<class T, T U> class A { T *x; };
T *x; // expected-error {{unknown type}}
template<class T *U> class B { T *x; };
T *y; // ok
struct C {
template<class T> void f(class D *p);
};
D *z; // ok
template<typename A = C, typename C = A> struct E {
void f() {
typedef ::dr481::C c; // expected-note {{previous}}
typedef C c; // expected-error {{different type}}
}
};
template struct E<>; // ok
template struct E<int>; // expected-note {{instantiation of}}
template<template<typename U_no_typo_correction> class A,
A<int> *B,
U_no_typo_correction *C> // expected-error {{unknown type}}
struct F {
U_no_typo_correction *x; // expected-error {{unknown type}}
};
template<template<class H *> class> struct G {
H *x;
};
H *q;
typedef int N;
template<N X, typename N, template<N Y> class T> struct I;
template<char*> struct J;
I<123, char*, J> *j;
}
namespace dr482 { // dr482: 3.5
extern int a;
void f();
int dr482::a = 0; // expected-warning {{extra qualification}}
void dr482::f() {} // expected-warning {{extra qualification}}
inline namespace X { // expected-error 0-1{{C++11 feature}}
extern int b;
void g();
struct S;
}
int dr482::b = 0; // expected-warning {{extra qualification}}
void dr482::g() {} // expected-warning {{extra qualification}}
struct dr482::S {}; // expected-warning {{extra qualification}}
void dr482::f(); // expected-warning {{extra qualification}}
void dr482::g(); // expected-warning {{extra qualification}}
// FIXME: The following are valid in DR482's wording, but these are bugs in
// the wording which we deliberately don't implement.
namespace N { typedef int type; }
typedef int N::type; // expected-error {{typedef declarator cannot be qualified}}
struct A {
struct B;
struct A::B {}; // expected-error {{extra qualification}}
#if __cplusplus >= 201103L
enum class C;
enum class A::C {}; // expected-error {{extra qualification}}
#endif
};
}
namespace dr483 { // dr483: yes
namespace climits {
int check1[__SCHAR_MAX__ >= 127 ? 1 : -1];
int check2[__SHRT_MAX__ >= 32767 ? 1 : -1];
int check3[__INT_MAX__ >= 32767 ? 1 : -1];
int check4[__LONG_MAX__ >= 2147483647 ? 1 : -1];
int check5[__LONG_LONG_MAX__ >= 9223372036854775807 ? 1 : -1];
#if __cplusplus < 201103L
// expected-error@-2 {{extension}}
#endif
}
namespace cstdint {
int check1[__PTRDIFF_WIDTH__ >= 16 ? 1 : -1];
int check2[__SIG_ATOMIC_WIDTH__ >= 8 ? 1 : -1];
int check3[__SIZE_WIDTH__ >= 16 ? 1 : -1];
int check4[__WCHAR_WIDTH__ >= 8 ? 1 : -1];
int check5[__WINT_WIDTH__ >= 16 ? 1 : -1];
}
}
namespace dr484 { // dr484: yes
struct A {
A();
void f();
};
typedef const A CA;
void CA::f() {
this->~CA();
this->CA::~A();
this->CA::A::~A();
}
CA::A() {}
struct B : CA {
B() : CA() {}
void f() { return CA::f(); }
};
struct C;
typedef C CT; // expected-note {{here}}
struct CT {}; // expected-error {{conflicts with typedef}}
namespace N {
struct D;
typedef D DT; // expected-note {{here}}
}
struct N::DT {}; // expected-error {{conflicts with typedef}}
typedef struct {
S(); // expected-error {{requires a type}}
} S;
}
namespace dr485 { // dr485: yes
namespace N {
struct S {};
int operator+(S, S);
template<typename T> int f(S);
}
template<typename T> int f();
N::S s;
int a = operator+(s, s);
int b = f<int>(s);
}
namespace dr486 { // dr486: yes
template<typename T> T f(T *); // expected-note 2{{substitution failure}}
int &f(...);
void g();
int n[10];
void h() {
int &a = f(&g);
int &b = f(&n);
f<void()>(&g); // expected-error {{no match}}
f<int[10]>(&n); // expected-error {{no match}}
}
}
namespace dr487 { // dr487: yes
enum E { e };
int operator+(int, E);
int i[4 + e]; // expected-error 2{{variable length array}}
}
namespace dr488 { // dr488: yes c++11
template <typename T> void f(T);
void f(int);
void g() {
// FIXME: It seems CWG thought this should be a SFINAE failure prior to
// allowing local types as template arguments. In C++98, we should either
// allow local types as template arguments or treat this as a SFINAE
// failure.
enum E { e };
f(e);
#if __cplusplus < 201103L
// expected-error@-2 {{local type}}
#endif
}
}
// dr489: na
namespace dr490 { // dr490: yes
template<typename T> struct X {};
struct A {
typedef int T;
struct K {}; // expected-note {{declared}}
int f(T);
int g(T);
int h(X<T>);
int X<T>::*i(); // expected-note {{previous}}
int K::*j();
template<typename T> T k();
operator X<T>();
};
struct B {
typedef char T;
typedef int U;
friend int A::f(T);
friend int A::g(U);
friend int A::h(X<T>);
// FIXME: Per this DR, these two are valid! That is another defect
// (no number yet...) which will eventually supersede this one.
friend int X<T>::*A::i(); // expected-error {{return type}}
friend int K::*A::j(); // expected-error {{undeclared identifier 'K'; did you mean 'A::K'?}}
// ok, lookup finds B::T, not A::T, so return type matches
friend char A::k<T>();
friend int A::k<U>();
// A conversion-type-id in a conversion-function-id is always looked up in
// the class of the conversion function first.
friend A::operator X<T>();
};
}
namespace dr491 { // dr491: dup 413
struct A {} a, b[3] = { a, {} };
A c[2] = { a, {}, b[1] }; // expected-error {{excess elements}}
}
// dr492 FIXME write a codegen test
namespace dr493 { // dr493: dup 976
struct X {
template <class T> operator const T &() const;
};
void f() {
if (X()) {
}
}
}
namespace dr494 { // dr494: dup 372
class A {
class B {};
friend class C;
};
class C : A::B {
A::B x;
class D : A::B {
A::B y;
};
};
}
namespace dr495 { // dr495: 3.5
template<typename T>
struct S {
operator int() { return T::error; }
template<typename U> operator U();
};
S<int> s;
long n = s;
template<typename T>
struct S2 {
template<typename U> operator U();
operator int() { return T::error; }
};
S2<int> s2;
long n2 = s2;
}
namespace dr496 { // dr496: no
struct A { int n; };
struct B { volatile int n; };
int check1[ __is_trivially_copyable(const int) ? 1 : -1];
int check2[!__is_trivially_copyable(volatile int) ? 1 : -1];
int check3[ __is_trivially_constructible(A, const A&) ? 1 : -1];
// FIXME: This is wrong.
int check4[ __is_trivially_constructible(B, const B&) ? 1 : -1];
int check5[ __is_trivially_assignable(A, const A&) ? 1 : -1];
// FIXME: This is wrong.
int check6[ __is_trivially_assignable(B, const B&) ? 1 : -1];
}
namespace dr497 { // dr497: yes
void before() {
struct S {
mutable int i;
};
const S cs; // expected-error {{default initialization}}
int S::*pm = &S::i;
cs.*pm = 88; // expected-error {{not assignable}}
}
void after() {
struct S {
S() : i(0) {}
mutable int i;
};
const S cs;
int S::*pm = &S::i;
cs.*pm = 88; // expected-error {{not assignable}}
}
}
namespace dr499 { // dr499: yes
extern char str[];
void f() { throw str; }
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr15xx.cpp
|
// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
#if __cplusplus < 201103L
// expected-no-diagnostics
#endif
namespace dr1550 { // dr1550: yes
int f(bool b, int n) {
return (b ? (throw 0) : n) + (b ? n : (throw 0));
}
}
namespace dr1560 { // dr1560: 3.5
void f(bool b, int n) {
(b ? throw 0 : n) = (b ? n : throw 0) = 0;
}
class X { X(const X&); };
const X &get();
const X &x = true ? get() : throw 0;
}
#if __cplusplus >= 201103L
namespace std {
typedef decltype(sizeof(int)) size_t;
// libc++'s implementation
template <class _E>
class initializer_list
{
const _E* __begin_;
size_t __size_;
initializer_list(const _E* __b, size_t __s)
: __begin_(__b), __size_(__s) {}
public:
typedef _E value_type;
typedef const _E& reference;
typedef const _E& const_reference;
typedef size_t size_type;
typedef const _E* iterator;
typedef const _E* const_iterator;
initializer_list() : __begin_(nullptr), __size_(0) {}
size_t size() const {return __size_;}
const _E* begin() const {return __begin_;}
const _E* end() const {return __begin_ + __size_;}
};
template < class _T1, class _T2 > struct pair { _T2 second; };
template<typename T> struct basic_string {
basic_string(const T* x) {}
~basic_string() {};
};
typedef basic_string<char> string;
} // std
namespace dr1589 { // dr1589: 3.7 c++11
// Ambiguous ranking of list-initialization sequences
void f0(long, int=0); // Would makes selection of #0 ambiguous
void f0(long); // #0
void f0(std::initializer_list<int>); // #00
void g0() { f0({1L}); } // chooses #00
void f1(int, int=0); // Would make selection of #1 ambiguous
void f1(int); // #1
void f1(std::initializer_list<long>); // #2
void g1() { f1({42}); } // chooses #2
void f2(std::pair<const char*, const char*>, int = 0); // Would makes selection of #3 ambiguous
void f2(std::pair<const char*, const char*>); // #3
void f2(std::initializer_list<std::string>); // #4
void g2() { f2({"foo","bar"}); } // chooses #4
namespace with_error {
void f0(long); // #0 expected-note {{candidate function}}
void f0(std::initializer_list<int>); // #00 expected-note {{candidate function}}
void f0(std::initializer_list<int>, int = 0); // Makes selection of #00 ambiguous \
// expected-note {{candidate function}}
void g0() { f0({1L}); } // chooses #00 expected-error{{call to 'f0' is ambiguous}}
void f1(int); // #1 expected-note {{candidate function}}
void f1(std::initializer_list<long>); // #2 expected-note {{candidate function}}
void f1(std::initializer_list<long>, int = 0); // Makes selection of #00 ambiguous \
// expected-note {{candidate function}}
void g1() { f1({42}); } // chooses #2 expected-error{{call to 'f1' is ambiguous}}
void f2(std::pair<const char*, const char*>); // #3 TODO: expected- note {{candidate function}}
void f2(std::initializer_list<std::string>); // #4 expected-note {{candidate function}}
void f2(std::initializer_list<std::string>, int = 0); // Makes selection of #00 ambiguous \
// expected-note {{candidate function}}
void g2() { f2({"foo","bar"}); } // chooses #4 expected-error{{call to 'f2' is ambiguous}}
}
} // dr1589
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr14xx.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
#if __cplusplus < 201103L
// expected-no-diagnostics
#endif
namespace dr1460 { // dr1460: 3.5
#if __cplusplus >= 201103L
namespace DRExample {
union A {
union {};
union {};
constexpr A() {}
};
constexpr A a = A();
union B {
union {};
union {};
constexpr B() = default;
};
constexpr B b = B();
union C {
union {};
union {};
};
constexpr C c = C();
#if __cplusplus > 201103L
constexpr void f() { C c; }
static_assert((f(), true), "");
#endif
}
union A {};
union B { int n; }; // expected-note +{{here}}
union C { int n = 0; };
struct D { union {}; };
struct E { union { int n; }; }; // expected-note +{{here}}
struct F { union { int n = 0; }; };
struct X {
friend constexpr A::A() noexcept;
friend constexpr B::B() noexcept; // expected-error {{follows non-constexpr declaration}}
friend constexpr C::C() noexcept;
friend constexpr D::D() noexcept;
friend constexpr E::E() noexcept; // expected-error {{follows non-constexpr declaration}}
friend constexpr F::F() noexcept;
};
// These are OK, because value-initialization doesn't actually invoke the
// constructor.
constexpr A a = A();
constexpr B b = B();
constexpr C c = C();
constexpr D d = D();
constexpr E e = E();
constexpr F f = F();
namespace Defaulted {
union A { constexpr A() = default; };
union B { int n; constexpr B() = default; }; // expected-error {{not constexpr}}
union C { int n = 0; constexpr C() = default; };
struct D { union {}; constexpr D() = default; };
struct E { union { int n; }; constexpr E() = default; }; // expected-error {{not constexpr}}
struct F { union { int n = 0; }; constexpr F() = default; };
struct G { union { int n = 0; }; union { int m; }; constexpr G() = default; }; // expected-error {{not constexpr}}
struct H {
union {
int n = 0;
};
union { // expected-note 2{{member not initialized}}
int m;
};
constexpr H() {} // expected-error {{must initialize all members}}
constexpr H(bool) : m(1) {}
constexpr H(char) : n(1) {} // expected-error {{must initialize all members}}
constexpr H(double) : m(1), n(1) {}
};
}
#if __cplusplus > 201103L
template<typename T> constexpr bool check() {
T t; // expected-note-re 2{{non-constexpr constructor '{{[BE]}}'}}
return true;
}
static_assert(check<A>(), "");
static_assert(check<B>(), ""); // expected-error {{constant}} expected-note {{in call}}
static_assert(check<C>(), "");
static_assert(check<D>(), "");
static_assert(check<E>(), ""); // expected-error {{constant}} expected-note {{in call}}
static_assert(check<F>(), "");
#endif
union G {
int a = 0; // expected-note {{previous initialization is here}}
int b = 0; // expected-error {{initializing multiple members of union}}
};
union H {
union {
int a = 0; // expected-note {{previous initialization is here}}
};
union {
int b = 0; // expected-error {{initializing multiple members of union}}
};
};
struct I {
union {
int a = 0; // expected-note {{previous initialization is here}}
int b = 0; // expected-error {{initializing multiple members of union}}
};
};
struct J {
union { int a = 0; };
union { int b = 0; };
};
namespace Overriding {
struct A {
int a = 1, b, c = 3;
constexpr A() : b(2) {}
};
static_assert(A().a == 1 && A().b == 2 && A().c == 3, "");
union B {
int a, b = 2, c;
constexpr B() : a(1) {}
constexpr B(char) : b(4) {}
constexpr B(int) : c(3) {}
constexpr B(const char*) {}
};
static_assert(B().a == 1, "");
static_assert(B().b == 2, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(B('x').a == 0, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(B('x').b == 4, "");
static_assert(B(123).b == 2, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(B(123).c == 3, "");
static_assert(B("").a == 1, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(B("").b == 2, "");
static_assert(B("").c == 3, ""); // expected-error {{constant}} expected-note {{read of}}
struct C {
union { int a, b = 2, c; };
union { int d, e = 5, f; };
constexpr C() : a(1) {}
constexpr C(char) : c(3) {}
constexpr C(int) : d(4) {}
constexpr C(float) : f(6) {}
constexpr C(const char*) {}
};
static_assert(C().a == 1, "");
static_assert(C().b == 2, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(C().d == 4, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(C().e == 5, "");
static_assert(C('x').b == 2, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(C('x').c == 3, "");
static_assert(C('x').d == 4, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(C('x').e == 5, "");
static_assert(C(1).b == 2, "");
static_assert(C(1).c == 3, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(C(1).d == 4, "");
static_assert(C(1).e == 5, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(C(1.f).b == 2, "");
static_assert(C(1.f).c == 3, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(C(1.f).e == 5, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(C(1.f).f == 6, "");
static_assert(C("").a == 1, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(C("").b == 2, "");
static_assert(C("").c == 3, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(C("").d == 4, ""); // expected-error {{constant}} expected-note {{read of}}
static_assert(C("").e == 5, "");
static_assert(C("").f == 6, ""); // expected-error {{constant}} expected-note {{read of}}
struct D;
extern const D d;
struct D {
int a;
union {
int b = const_cast<D&>(d).a = 1; // not evaluated
int c;
};
constexpr D() : a(0), c(0) {}
};
constexpr D d {};
static_assert(d.a == 0, "");
}
#endif
}
#if __cplusplus >= 201103L
namespace std {
typedef decltype(sizeof(int)) size_t;
// libc++'s implementation
template <class _E>
class initializer_list
{
const _E* __begin_;
size_t __size_;
initializer_list(const _E* __b, size_t __s)
: __begin_(__b), __size_(__s) {}
public:
typedef _E value_type;
typedef const _E& reference;
typedef const _E& const_reference;
typedef size_t size_type;
typedef const _E* iterator;
typedef const _E* const_iterator;
initializer_list() : __begin_(nullptr), __size_(0) {}
size_t size() const {return __size_;}
const _E* begin() const {return __begin_;}
const _E* end() const {return __begin_ + __size_;}
};
} // std
namespace dr1467 { // dr1467: 3.7 c++11
// List-initialization of aggregate from same-type object
namespace basic0 {
struct S {
int i = 42;
};
S a;
S b(a);
S c{a};
struct SS : public S { } x;
S y(x);
S z{x};
} // basic0
namespace basic1 {
struct S {
int i{42};
};
S a;
S b(a);
S c{a};
struct SS : public S { } x;
S y(x);
S z{x};
} // basic1
namespace basic2 {
struct S {
int i = {42};
};
S a;
S b(a);
S c{a};
struct SS : public S { } x;
S y(x);
S z{x};
} // basic2
namespace dr_example {
struct OK {
OK() = default;
OK(const OK&) = default;
OK(int) { }
};
OK ok;
OK ok2{ok};
struct X {
X() = default;
X(const X&) = default;
};
X x;
X x2{x};
} // dr_example
namespace nonaggregate {
struct NonAggregate {
NonAggregate() {}
};
struct WantsIt {
WantsIt(NonAggregate);
};
void f(NonAggregate);
void f(WantsIt);
void test1() {
NonAggregate n;
f({n});
}
void test2() {
NonAggregate x;
NonAggregate y{x};
NonAggregate z{{x}};
}
} // nonaggregate
namespace SelfInitIsNotListInit {
struct S {
S();
explicit S(S &);
S(const S &);
};
S s1;
S s2 = {s1}; // ok, not list-initialization so we pick the non-explicit constructor
}
struct NestedInit { int a, b, c; };
NestedInit ni[1] = {{NestedInit{1, 2, 3}}};
namespace NestedInit2 {
struct Pair { int a, b; };
struct TwoPairs { TwoPairs(Pair, Pair); };
struct Value { Value(Pair); Value(TwoPairs); };
void f() { Value{{{1,2},{3,4}}}; }
}
} // dr1467
namespace dr1490 { // dr1490: 3.7 c++11
// List-initialization from a string literal
char s[4]{"abc"}; // Ok
std::initializer_list<char>{"abc"}; // expected-error {{expected unqualified-id}}}
} // dr190
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr2xx.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// PR13819 -- __SIZE_TYPE__ is incompatible.
typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}}
#if __cplusplus < 201103L
#define fold(x) (__builtin_constant_p(x) ? (x) : (x))
#else
#define fold
#endif
namespace dr200 { // dr200: dup 214
template <class T> T f(int);
template <class T, class U> T f(U) = delete; // expected-error 0-1{{extension}}
void g() {
f<int>(1);
}
}
// dr201 FIXME: write codegen test
namespace dr202 { // dr202: yes
template<typename T> T f();
template<int (*g)()> struct X {
int arr[fold(g == &f<int>) ? 1 : -1];
};
template struct X<f>;
}
// FIXME (export) dr204: no
namespace dr206 { // dr206: yes
struct S; // expected-note 2{{declaration}}
template<typename T> struct Q { S s; }; // expected-error {{incomplete}}
template<typename T> void f() { S s; } // expected-error {{incomplete}}
}
namespace dr207 { // dr207: yes
class A {
protected:
static void f() {}
};
class B : A {
public:
using A::f;
void g() {
A::f();
f();
}
};
}
// dr208 FIXME: write codegen test
namespace dr209 { // dr209: yes
class A {
void f(); // expected-note {{here}}
};
class B {
friend void A::f(); // expected-error {{private}}
};
}
// dr210 FIXME: write codegen test
namespace dr211 { // dr211: yes
struct A {
A() try {
throw 0;
} catch (...) {
return; // expected-error {{return in the catch of a function try block of a constructor}}
}
};
}
namespace dr213 { // dr213: yes
template <class T> struct A : T {
void h(T t) {
char &r1 = f(t);
int &r2 = g(t); // expected-error {{undeclared}}
}
};
struct B {
int &f(B);
int &g(B); // expected-note {{in dependent base class}}
};
char &f(B);
template void A<B>::h(B); // expected-note {{instantiation}}
}
namespace dr214 { // dr214: yes
template<typename T, typename U> T checked_cast(U from) { U::error; }
template<typename T, typename U> T checked_cast(U *from);
class C {};
void foo(int *arg) { checked_cast<const C *>(arg); }
template<typename T> T f(int);
template<typename T, typename U> T f(U) { T::error; }
void g() {
f<int>(1);
}
}
namespace dr215 { // dr215: yes
template<typename T> class X {
friend void T::foo();
int n;
};
struct Y {
void foo() { (void)+X<Y>().n; }
};
}
namespace dr216 { // dr216: no
// FIXME: Should reject this: 'f' has linkage but its type does not,
// and 'f' is odr-used but not defined in this TU.
typedef enum { e } *E;
void f(E);
void g(E e) { f(e); }
struct S {
// FIXME: Should reject this: 'f' has linkage but its type does not,
// and 'f' is odr-used but not defined in this TU.
typedef enum { e } *E;
void f(E);
};
void g(S s, S::E e) { s.f(e); }
}
namespace dr217 { // dr217: yes
template<typename T> struct S {
void f(int);
};
template<typename T> void S<T>::f(int = 0) {} // expected-error {{default arguments cannot be added}}
}
namespace dr218 { // dr218: yes
namespace A {
struct S {};
void f(S);
}
namespace B {
struct S {};
void f(S);
}
struct C {
int f;
void test1(A::S as) { f(as); } // expected-error {{called object type 'int'}}
void test2(A::S as) { void f(); f(as); } // expected-error {{too many arguments}} expected-note {{}}
void test3(A::S as) { using A::f; f(as); } // ok
void test4(A::S as) { using B::f; f(as); } // ok
void test5(A::S as) { int f; f(as); } // expected-error {{called object type 'int'}}
void test6(A::S as) { struct f {}; (void) f(as); } // expected-error {{no matching conversion}} expected-note +{{}}
};
namespace D {
struct S {};
struct X { void operator()(S); } f;
}
void testD(D::S ds) { f(ds); } // expected-error {{undeclared identifier}}
namespace E {
struct S {};
struct f { f(S); };
}
void testE(E::S es) { f(es); } // expected-error {{undeclared identifier}}
namespace F {
struct S {
template<typename T> friend void f(S, T) {}
};
}
void testF(F::S fs) { f(fs, 0); }
namespace G {
namespace X {
int f;
struct A {};
}
namespace Y {
template<typename T> void f(T);
struct B {};
}
template<typename A, typename B> struct C {};
}
void testG(G::C<G::X::A, G::Y::B> gc) { f(gc); }
}
// dr219: na
// dr220: na
namespace dr221 { // dr221: yes
struct A { // expected-note 2-4{{candidate}}
A &operator=(int&); // expected-note 2{{candidate}}
A &operator+=(int&);
static A &operator=(A&, double&); // expected-error {{cannot be a static member}}
static A &operator+=(A&, double&); // expected-error {{cannot be a static member}}
friend A &operator=(A&, char&); // expected-error {{must be a non-static member function}}
friend A &operator+=(A&, char&);
};
A &operator=(A&, float&); // expected-error {{must be a non-static member function}}
A &operator+=(A&, float&);
void test(A a, int n, char c, float f) {
a = n;
a += n;
a = c; // expected-error {{no viable}}
a += c;
a = f; // expected-error {{no viable}}
a += f;
}
}
namespace dr222 { // dr222: dup 637
void f(int a, int b, int c, int *x) {
#pragma clang diagnostic push
#pragma clang diagnostic warning "-Wunsequenced"
void((a += b) += c);
void((a += b) + (a += c)); // expected-warning {{multiple unsequenced modifications to 'a'}}
x[a++] = a; // expected-warning {{unsequenced modification and access to 'a'}}
a = b = 0; // ok, read and write of 'b' are sequenced
a = (b = a++); // expected-warning {{multiple unsequenced modifications to 'a'}}
a = (b = ++a);
#pragma clang diagnostic pop
}
}
// dr223: na
namespace dr224 { // dr224: no
namespace example1 {
template <class T> class A {
typedef int type;
A::type a;
A<T>::type b;
A<T*>::type c; // expected-error {{missing 'typename'}}
::dr224::example1::A<T>::type d;
class B {
typedef int type;
A::type a;
A<T>::type b;
A<T*>::type c; // expected-error {{missing 'typename'}}
::dr224::example1::A<T>::type d;
B::type e;
A<T>::B::type f;
A<T*>::B::type g; // expected-error {{missing 'typename'}}
typename A<T*>::B::type h;
};
};
template <class T> class A<T*> {
typedef int type;
A<T*>::type a;
A<T>::type b; // expected-error {{missing 'typename'}}
};
template <class T1, class T2, int I> struct B {
typedef int type;
B<T1, T2, I>::type b1;
B<T2, T1, I>::type b2; // expected-error {{missing 'typename'}}
typedef T1 my_T1;
static const int my_I = I;
static const int my_I2 = I+0;
static const int my_I3 = my_I;
B<my_T1, T2, my_I>::type b3; // FIXME: expected-error {{missing 'typename'}}
B<my_T1, T2, my_I2>::type b4; // expected-error {{missing 'typename'}}
B<my_T1, T2, my_I3>::type b5; // FIXME: expected-error {{missing 'typename'}}
};
}
namespace example2 {
template <int, typename T> struct X { typedef T type; };
template <class T> class A {
static const int i = 5;
X<i, int>::type w; // FIXME: expected-error {{missing 'typename'}}
X<A::i, char>::type x; // FIXME: expected-error {{missing 'typename'}}
X<A<T>::i, double>::type y; // FIXME: expected-error {{missing 'typename'}}
X<A<T*>::i, long>::type z; // expected-error {{missing 'typename'}}
int f();
};
template <class T> int A<T>::f() {
return i;
}
}
}
// dr225: yes
template<typename T> void dr225_f(T t) { dr225_g(t); } // expected-error {{call to function 'dr225_g' that is neither visible in the template definition nor found by argument-dependent lookup}}
void dr225_g(int); // expected-note {{should be declared prior to the call site}}
template void dr225_f(int); // expected-note {{in instantiation of}}
namespace dr226 { // dr226: no
template<typename T = void> void f() {}
#if __cplusplus < 201103L
// expected-error@-2 {{extension}}
// FIXME: This appears to be wrong: default arguments for function templates
// are listed as a defect (in c++98) not an extension. EDG accepts them in
// strict c++98 mode.
#endif
template<typename T> struct S {
template<typename U = void> void g();
#if __cplusplus < 201103L
// expected-error@-2 {{extension}}
#endif
template<typename U> struct X;
template<typename U> void h();
};
template<typename T> template<typename U> void S<T>::g() {}
template<typename T> template<typename U = void> struct S<T>::X {}; // expected-error {{cannot add a default template arg}}
template<typename T> template<typename U = void> void S<T>::h() {} // expected-error {{cannot add a default template arg}}
template<typename> void friend_h();
struct A {
// FIXME: This is ill-formed.
template<typename=void> struct friend_B;
// FIXME: f, h, and i are ill-formed.
// f is ill-formed because it is not a definition.
// h and i are ill-formed because they are not the only declarations of the
// function in the translation unit.
template<typename=void> void friend_f();
template<typename=void> void friend_g() {}
template<typename=void> void friend_h() {}
template<typename=void> void friend_i() {}
#if __cplusplus < 201103L
// expected-error@-5 {{extension}} expected-error@-4 {{extension}}
// expected-error@-4 {{extension}} expected-error@-3 {{extension}}
#endif
};
template<typename> void friend_i();
template<typename=void, typename X> void foo(X) {}
template<typename=void, typename X> struct Foo {}; // expected-error {{missing a default argument}} expected-note {{here}}
#if __cplusplus < 201103L
// expected-error@-3 {{extension}}
#endif
template<typename=void, typename X, typename, typename Y> int foo(X, Y);
template<typename, typename X, typename=void, typename Y> int foo(X, Y);
int x = foo(0, 0);
#if __cplusplus < 201103L
// expected-error@-4 {{extension}}
// expected-error@-4 {{extension}}
#endif
}
void dr227(bool b) { // dr227: yes
if (b)
int n;
else
int n;
}
namespace dr228 { // dr228: yes
template <class T> struct X {
void f();
};
template <class T> struct Y {
void g(X<T> x) { x.template X<T>::f(); }
};
}
namespace dr229 { // dr229: yes
template<typename T> void f();
template<typename T> void f<T*>() {} // expected-error {{function template partial specialization}}
template<> void f<int>() {}
}
namespace dr230 { // dr230: yes
struct S {
S() { f(); } // expected-warning {{call to pure virtual member function}}
virtual void f() = 0; // expected-note {{declared here}}
};
}
namespace dr231 { // dr231: yes
namespace outer {
namespace inner {
int i; // expected-note {{here}}
}
void f() { using namespace inner; }
int j = i; // expected-error {{undeclared identifier 'i'; did you mean 'inner::i'?}}
}
}
// dr234: na
// dr235: na
namespace dr236 { // dr236: yes
void *p = int();
#if __cplusplus < 201103L
// expected-warning@-2 {{null pointer}}
#else
// expected-error@-4 {{cannot initialize}}
#endif
}
namespace dr237 { // dr237: dup 470
template<typename T> struct A { void f() { T::error; } };
template<typename T> struct B : A<T> {};
template struct B<int>; // ok
}
namespace dr239 { // dr239: yes
namespace NS {
class T {};
void f(T);
float &g(T, int);
}
NS::T parm;
int &g(NS::T, float);
int main() {
f(parm);
float &r = g(parm, 1);
extern int &g(NS::T, float);
int &s = g(parm, 1);
}
}
// dr240: dup 616
namespace dr241 { // dr241: yes
namespace A {
struct B {};
template <int X> void f(); // expected-note 2{{candidate}}
template <int X> void g(B);
}
namespace C {
template <class T> void f(T t); // expected-note 2{{candidate}}
template <class T> void g(T t); // expected-note {{candidate}}
}
void h(A::B b) {
f<3>(b); // expected-error {{undeclared identifier}}
g<3>(b); // expected-error {{undeclared identifier}}
A::f<3>(b); // expected-error {{no matching}}
A::g<3>(b);
C::f<3>(b); // expected-error {{no matching}}
C::g<3>(b); // expected-error {{no matching}}
using C::f;
using C::g;
f<3>(b); // expected-error {{no matching}}
g<3>(b);
}
}
namespace dr243 { // dr243: yes
struct B;
struct A {
A(B); // expected-note {{candidate}}
};
struct B {
operator A() = delete; // expected-error 0-1{{extension}} expected-note {{candidate}}
} b;
A a1(b);
A a2 = b; // expected-error {{ambiguous}}
}
namespace dr244 { // dr244: partial
struct B {}; struct D : B {}; // expected-note {{here}}
D D_object;
typedef B B_alias;
B* B_ptr = &D_object;
void f() {
D_object.~B(); // expected-error {{expression does not match the type}}
D_object.B::~B();
B_ptr->~B();
B_ptr->~B_alias();
B_ptr->B_alias::~B();
// This is valid under DR244.
B_ptr->B_alias::~B_alias();
B_ptr->dr244::~B(); // expected-error {{refers to a member in namespace}}
B_ptr->dr244::~B_alias(); // expected-error {{refers to a member in namespace}}
}
namespace N {
template<typename T> struct E {};
typedef E<int> F;
}
void g(N::F f) {
typedef N::F G;
f.~G();
f.G::~E();
f.G::~F(); // expected-error {{expected the class name after '~' to name a destructor}}
f.G::~G();
// This is technically ill-formed; E is looked up in 'N::' and names the
// class template, not the injected-class-name of the class. But that's
// probably a bug in the standard.
f.N::F::~E();
// This is valid; we look up the second F in the same scope in which we
// found the first one, that is, 'N::'.
f.N::F::~F(); // FIXME: expected-error {{expected the class name after '~' to name a destructor}}
// This is technically ill-formed; G is looked up in 'N::' and is not found;
// as above, this is probably a bug in the standard.
f.N::F::~G();
}
}
namespace dr245 { // dr245: yes
struct S {
enum E {}; // expected-note {{here}}
class E *p; // expected-error {{does not match previous declaration}}
};
}
namespace dr246 { // dr246: yes
struct S {
S() try { // expected-note {{try block}}
throw 0;
X: ;
} catch (int) {
goto X; // expected-error {{cannot jump}}
}
};
}
namespace dr247 { // dr247: yes
struct A {};
struct B : A {
void f();
void f(int);
};
void (A::*f)() = (void (A::*)())&B::f;
struct C {
void f();
void f(int);
};
struct D : C {};
void (C::*g)() = &D::f;
void (D::*h)() = &D::f;
struct E {
void f();
};
struct F : E {
using E::f;
void f(int);
};
void (F::*i)() = &F::f;
}
namespace dr248 { // dr248: yes c++11
// FIXME: Should this also apply to c++98 mode? This was a DR against C++98.
int \u040d\u040e = 0;
#if __cplusplus < 201103L
// FIXME: expected-error@-2 {{expected ';'}}
#endif
}
namespace dr249 { // dr249: yes
template<typename T> struct X { void f(); };
template<typename T> void X<T>::f() {}
}
namespace dr250 { // dr250: yes
typedef void (*FPtr)(double x[]);
template<int I> void f(double x[]);
FPtr fp = &f<3>;
template<int I = 3> void g(double x[]); // expected-error 0-1{{extension}}
FPtr gp = &g<>;
}
namespace dr252 { // dr252: yes
struct A {
void operator delete(void*); // expected-note {{found}}
};
struct B {
void operator delete(void*); // expected-note {{found}}
};
struct C : A, B {
virtual ~C();
};
C::~C() {} // expected-error {{'operator delete' found in multiple base classes}}
struct D {
void operator delete(void*, int); // expected-note {{here}}
virtual ~D();
};
D::~D() {} // expected-error {{no suitable member 'operator delete'}}
struct E {
void operator delete(void*, int);
void operator delete(void*) = delete; // expected-error 0-1{{extension}} expected-note 1-2 {{here}}
virtual ~E(); // expected-error 0-1 {{attempt to use a deleted function}}
};
E::~E() {} // expected-error {{attempt to use a deleted function}}
struct F {
// If both functions are available, the first one is a placement delete.
void operator delete(void*, size_t);
void operator delete(void*) = delete; // expected-error 0-1{{extension}} expected-note {{here}}
virtual ~F();
};
F::~F() {} // expected-error {{attempt to use a deleted function}}
struct G {
void operator delete(void*, size_t);
virtual ~G();
};
G::~G() {}
}
namespace dr254 { // dr254: yes
template<typename T> struct A {
typedef typename T::type type; // ok even if this is a typedef-name, because
// it's not an elaborated-type-specifier
typedef struct T::type foo; // expected-error {{elaborated type refers to a typedef}}
};
struct B { struct type {}; };
struct C { typedef struct {} type; }; // expected-note {{here}}
A<B>::type n;
A<C>::type n; // expected-note {{instantiation of}}
}
// dr256: dup 624
namespace dr257 { // dr257: yes
struct A { A(int); }; // expected-note {{here}}
struct B : virtual A {
B() {}
virtual void f() = 0;
};
struct C : B {
C() {}
};
struct D : B {
D() {} // expected-error {{must explicitly initialize the base class 'dr257::A'}}
void f();
};
}
namespace dr258 { // dr258: yes
struct A {
void f(const int);
template<typename> void g(int);
float &h() const;
};
struct B : A {
using A::f;
using A::g;
using A::h;
int &f(int);
template<int> int &g(int); // expected-note {{candidate}}
int &h();
} b;
int &w = b.f(0);
int &x = b.g<int>(0); // expected-error {{no match}}
int &y = b.h();
float &z = const_cast<const B&>(b).h();
struct C {
virtual void f(const int) = 0;
};
struct D : C {
void f(int);
} d;
struct E {
virtual void f() = 0; // expected-note {{unimplemented}}
};
struct F : E {
void f() const {}
} f; // expected-error {{abstract}}
}
namespace dr259 { // dr259: yes c++11
template<typename T> struct A {};
template struct A<int>; // expected-note {{previous}}
template struct A<int>; // expected-error {{duplicate explicit instantiation}}
// FIXME: We only apply this DR in C++11 mode.
template<> struct A<float>;
template struct A<float>;
#if __cplusplus < 201103L
// expected-error@-2 {{extension}} expected-note@-3 {{here}}
#endif
template struct A<char>; // expected-note {{here}}
template<> struct A<char>; // expected-error {{explicit specialization of 'dr259::A<char>' after instantiation}}
template<> struct A<double>;
template<> struct A<double>;
template<> struct A<double> {}; // expected-note {{here}}
template<> struct A<double> {}; // expected-error {{redefinition}}
template<typename T> struct B; // expected-note {{here}}
template struct B<int>; // expected-error {{undefined}}
template<> struct B<float>;
template struct B<float>;
#if __cplusplus < 201103L
// expected-error@-2 {{extension}} expected-note@-3 {{here}}
#endif
}
// FIXME: When dr260 is resolved, also add tests for DR507.
namespace dr261 { // dr261: no
#pragma clang diagnostic push
#pragma clang diagnostic warning "-Wused-but-marked-unused"
// FIXME: This is ill-formed, with a diagnostic required, because operator new
// and operator delete are inline and odr-used, but not defined in this
// translation unit.
// We're also missing the -Wused-but-marked-unused diagnostic here.
struct A {
inline void *operator new(size_t) __attribute__((unused));
inline void operator delete(void*) __attribute__((unused));
A() {}
};
// FIXME: These are ill-formed, with a required diagnostic, for the same
// reason.
struct B {
inline void operator delete(void*) __attribute__((unused));
~B() {}
};
struct C {
inline void operator delete(void*) __attribute__((unused));
virtual ~C() {}
};
struct D {
inline void operator delete(void*) __attribute__((unused));
};
void h() { C::operator delete(0); } // expected-warning {{marked unused but was used}}
#pragma clang diagnostic pop
}
namespace dr262 { // dr262: yes
int f(int = 0, ...);
int k = f();
int l = f(0);
int m = f(0, 0);
}
namespace dr263 { // dr263: yes
struct X {};
struct Y {
#if __cplusplus < 201103L
friend X::X() throw();
friend X::~X() throw();
#else
friend constexpr X::X() noexcept;
friend X::~X();
#endif
Y::Y(); // expected-error {{extra qualification}}
Y::~Y(); // expected-error {{extra qualification}}
};
}
// dr265: dup 353
// dr266: na
// dr269: na
// dr270: na
namespace dr272 { // dr272: yes
struct X {
void f() {
this->~X();
X::~X();
~X(); // expected-error {{unary expression}}
}
};
}
#include <stdarg.h>
#include <stddef.h>
namespace dr273 { // dr273: yes
struct A {
int n;
};
void operator&(A);
void f(A a, ...) {
offsetof(A, n);
va_list val;
va_start(val, a);
va_end(val);
}
}
// dr274: na
namespace dr275 { // dr275: no
namespace N {
template <class T> void f(T) {} // expected-note 1-4{{here}}
template <class T> void g(T) {} // expected-note {{candidate}}
template <> void f(int);
template <> void f(char);
template <> void f(double);
template <> void g(char);
}
using namespace N;
namespace M {
template <> void N::f(char) {} // expected-error {{'M' does not enclose namespace 'N'}}
template <class T> void g(T) {}
template <> void g(char) {}
template void f(long);
#if __cplusplus >= 201103L
// FIXME: this should be rejected in c++98 too
// expected-error@-3 {{must occur in namespace 'N'}}
#endif
template void N::f(unsigned long);
#if __cplusplus >= 201103L
// FIXME: this should be rejected in c++98 too
// expected-error@-3 {{not in a namespace enclosing 'N'}}
#endif
template void h(long); // expected-error {{does not refer to a function template}}
template <> void f(double) {} // expected-error {{no function template matches}}
}
template <class T> void g(T) {} // expected-note {{candidate}}
template <> void N::f(char) {}
template <> void f(int) {} // expected-error {{no function template matches}}
template void f(short);
#if __cplusplus >= 201103L
// FIXME: this should be rejected in c++98 too
// expected-error@-3 {{must occur in namespace 'N'}}
#endif
template void N::f(unsigned short);
// FIXME: this should probably be valid. the wording from the issue
// doesn't clarify this, but it follows from the usual rules.
template void g(int); // expected-error {{ambiguous}}
// FIXME: likewise, this should also be valid.
template<typename T> void f(T) {} // expected-note {{candidate}}
template void f(short); // expected-error {{ambiguous}}
}
// dr276: na
namespace dr277 { // dr277: yes
typedef int *intp;
int *p = intp();
int a[fold(intp() ? -1 : 1)];
}
namespace dr280 { // dr280: yes
typedef void f0();
typedef void f1(int);
typedef void f2(int, int);
typedef void f3(int, int, int);
struct A {
operator f1*(); // expected-note {{here}} expected-note {{candidate}}
operator f2*();
};
struct B {
operator f0*(); // expected-note {{candidate}}
private:
operator f3*(); // expected-note {{here}} expected-note {{candidate}}
};
struct C {
operator f0*(); // expected-note {{candidate}}
operator f1*(); // expected-note {{candidate}}
operator f2*(); // expected-note {{candidate}}
operator f3*(); // expected-note {{candidate}}
};
struct D : private A, B { // expected-note 2{{here}}
operator f2*(); // expected-note {{candidate}}
} d;
struct E : C, D {} e;
void g() {
d(); // ok, public
d(0); // expected-error {{private member of 'dr280::A'}} expected-error {{private base class 'dr280::A'}}
d(0, 0); // ok, suppressed by member in D
d(0, 0, 0); // expected-error {{private member of 'dr280::B'}}
e(); // expected-error {{ambiguous}}
e(0); // expected-error {{ambiguous}}
e(0, 0); // expected-error {{ambiguous}}
e(0, 0, 0); // expected-error {{ambiguous}}
}
}
namespace dr281 { // dr281: no
void a();
inline void b();
void d();
inline void e();
struct S {
friend inline void a(); // FIXME: ill-formed
friend inline void b();
friend inline void c(); // FIXME: ill-formed
friend inline void d() {}
friend inline void e() {}
friend inline void f() {}
};
}
namespace dr283 { // dr283: yes
template<typename T> // expected-note 2{{here}}
struct S {
friend class T; // expected-error {{shadows}}
class T; // expected-error {{shadows}}
};
}
namespace dr284 { // dr284: no
namespace A {
struct X;
enum Y {};
class Z {};
}
namespace B {
struct W;
using A::X;
using A::Y;
using A::Z;
}
struct B::V {}; // expected-error {{no struct named 'V'}}
struct B::W {};
struct B::X {}; // FIXME: ill-formed
enum B::Y e; // ok per dr417
class B::Z z; // ok per dr417
struct C {
struct X;
enum Y {};
class Z {};
};
struct D : C {
struct W;
using C::X;
using C::Y;
using C::Z;
};
struct D::V {}; // expected-error {{no struct named 'V'}}
struct D::W {};
struct D::X {}; // FIXME: ill-formed
enum D::Y e2; // ok per dr417
class D::Z z2; // ok per dr417
}
namespace dr285 { // dr285: yes
template<typename T> void f(T, int); // expected-note {{match}}
template<typename T> void f(int, T); // expected-note {{match}}
template<> void f<int>(int, int) {} // expected-error {{ambiguous}}
}
namespace dr286 { // dr286: yes
template<class T> struct A {
class C {
template<class T2> struct B {}; // expected-note {{here}}
};
};
template<class T>
template<class T2>
struct A<T>::C::B<T2*> { };
A<short>::C::B<int*> absip; // expected-error {{private}}
}
// dr288: na
namespace dr289 { // dr289: yes
struct A; // expected-note {{forward}}
struct B : A {}; // expected-error {{incomplete}}
template<typename T> struct C { typename T::error error; }; // expected-error {{cannot be used prior to '::'}}
struct D : C<int> {}; // expected-note {{instantiation}}
}
// dr290: na
// dr291: dup 391
// dr292 FIXME: write a codegen test
namespace dr294 { // dr294: no
void f() throw(int);
int main() {
(void)static_cast<void (*)() throw()>(f); // FIXME: ill-formed
(void)static_cast<void (*)() throw(int)>(f); // FIXME: ill-formed
void (*p)() throw() = f; // expected-error {{not superset}}
void (*q)() throw(int) = f;
}
}
namespace dr295 { // dr295: 3.7
typedef int f();
const f g; // expected-warning {{'const' qualifier on function type 'f' (aka 'int ()') has no effect}}
f &r = g;
template<typename T> struct X {
const T &f;
};
X<f> x = {g};
typedef int U();
typedef const U U; // expected-warning {{'const' qualifier on function type 'U' (aka 'int ()') has no effect}}
typedef int (*V)();
typedef volatile U *V; // expected-warning {{'volatile' qualifier on function type 'U' (aka 'int ()') has no effect}}
}
namespace dr296 { // dr296: yes
struct A {
static operator int() { return 0; } // expected-error {{static}}
};
}
namespace dr298 { // dr298: yes
struct A {
typedef int type;
A();
~A();
};
typedef A B; // expected-note {{here}}
typedef const A C; // expected-note {{here}}
A::type i1;
B::type i2;
C::type i3;
struct A a;
struct B b; // expected-error {{refers to a typedef}}
struct C c; // expected-error {{refers to a typedef}}
B::B() {} // expected-error {{requires a type specifier}}
B::A() {} // ok
C::~C() {} // expected-error {{destructor cannot be declared using a typedef 'C' (aka 'const dr298::A') of the class name}}
typedef struct D E; // expected-note {{here}}
struct E {}; // expected-error {{conflicts with typedef}}
struct F {
~F();
};
typedef const F G;
G::~F() {} // ok
}
namespace dr299 { // dr299: yes c++11
struct S {
operator int();
};
struct T {
operator int(); // expected-note {{}}
operator unsigned short(); // expected-note {{}}
};
// FIXME: should this apply to c++98 mode?
int *p = new int[S()]; // expected-error 0-1{{extension}}
int *q = new int[T()]; // expected-error {{ambiguous}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr412.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT="throw()" -DBAD_ALLOC="throw(std::bad_alloc)"
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -DNOEXCEPT=noexcept -DBAD_ALLOC=
// dr412: yes
// lwg404: yes
// lwg2340: yes
// FIXME: __SIZE_TYPE__ expands to 'long long' on some targets.
__extension__ typedef __SIZE_TYPE__ size_t;
namespace std { struct bad_alloc {}; }
inline void* operator new(size_t) BAD_ALLOC; // expected-error {{cannot be declared 'inline'}}
inline void* operator new[](size_t) BAD_ALLOC; // expected-error {{cannot be declared 'inline'}}
inline void operator delete(void*) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
inline void operator delete[](void*) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
#ifdef __cpp_sized_deallocation
inline void operator delete(void*, size_t) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
inline void operator delete[](void*, size_t) NOEXCEPT; // expected-error {{cannot be declared 'inline'}}
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr16xx.cpp
|
// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
#if __cplusplus < 201103L
// expected-no-diagnostics
#endif
namespace dr1684 { // dr1684: 3.6
#if __cplusplus >= 201103L
struct NonLiteral { // expected-note {{because}}
NonLiteral();
constexpr int f() { return 0; } // expected-warning 0-1{{will not be implicitly 'const'}}
};
constexpr int f(NonLiteral &) { return 0; }
constexpr int f(NonLiteral) { return 0; } // expected-error {{not a literal type}}
#endif
}
#if __cplusplus >= 201103L
namespace dr1631 { // dr1631: 3.7 c++11
// Incorrect overload resolution for single-element initializer-list
struct A { int a[1]; };
struct B { B(int); };
void f(B, int);
void f(B, int, int = 0);
void f(int, A);
void test() {
f({0}, {{1}}); // expected-warning {{braces around scalar init}}
}
namespace with_error {
void f(B, int); // TODO: expected- note {{candidate function}}
void f(int, A); // expected-note {{candidate function}}
void f(int, A, int = 0); // expected-note {{candidate function}}
void test() {
f({0}, {{1}}); // expected-error{{call to 'f' is ambiguous}}
}
}
} // dr1631
#endif
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr9xx.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
#if __cplusplus < 201103L
// expected-no-diagnostics
#endif
namespace std {
__extension__ typedef __SIZE_TYPE__ size_t;
template<typename T> struct initializer_list {
const T *p; size_t n;
initializer_list(const T *p, size_t n);
};
}
namespace dr990 { // dr990: 3.5
#if __cplusplus >= 201103L
struct A { // expected-note 2{{candidate}}
A(std::initializer_list<int>); // expected-note {{candidate}}
};
struct B {
A a;
};
B b1 { };
B b2 { 1 }; // expected-error {{no viable conversion from 'int' to 'dr990::A'}}
B b3 { { 1 } };
struct C {
C();
C(int);
C(std::initializer_list<int>) = delete; // expected-note {{here}}
};
C c1[3] { 1 }; // ok
C c2[3] { 1, {2} }; // expected-error {{call to deleted}}
struct D {
D();
D(std::initializer_list<int>);
D(std::initializer_list<double>);
};
D d{};
#endif
}
namespace dr948 { // dr948: 3.7
#if __cplusplus >= 201103L
class A {
public:
constexpr A(int v) : v(v) { }
constexpr operator int() const { return v; }
private:
int v;
};
constexpr int id(int x)
{
return x;
}
void f() {
if (constexpr int i = id(101)) { }
switch (constexpr int i = id(2)) { default: break; case 2: break; }
for (; constexpr int i = id(0); ) { }
while (constexpr int i = id(0)) { }
if (constexpr A i = 101) { }
switch (constexpr A i = 2) { default: break; case 2: break; }
for (; constexpr A i = 0; ) { }
while (constexpr A i = 0) { }
}
#endif
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr5xx.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// FIXME: This is included to avoid a diagnostic with no source location
// pointing at the implicit operator new. We can't match such a diagnostic
// with -verify.
__extension__ typedef __SIZE_TYPE__ size_t;
void *operator new(size_t); // expected-warning 0-1{{missing exception spec}} expected-note{{candidate}}
namespace dr500 { // dr500: dup 372
class D;
class A {
class B;
class C;
friend class D;
};
class A::B {};
class A::C : public A::B {};
class D : public A::B {};
}
namespace dr501 { // dr501: yes
struct A {
friend void f() {}
void g() {
void (*p)() = &f; // expected-error {{undeclared identifier}}
}
};
}
namespace dr502 { // dr502: yes
struct Q {};
template<typename T> struct A {
enum E { e = 1 };
void q1() { f(e); }
void q2() { Q arr[sizeof(E)]; f(arr); }
void q3() { Q arr[e]; f(arr); }
void sanity() { Q arr[1]; f(arr); } // expected-error {{undeclared identifier 'f'}}
};
int f(A<int>::E);
template<int N> int f(Q (&)[N]);
template struct A<int>;
}
namespace dr505 { // dr505: yes
const char *exts = "\e\(\{\[\%"; // expected-error 5{{use of non-standard escape}}
const char *unknown = "\Q"; // expected-error {{unknown escape sequence}}
}
namespace dr506 { // dr506: yes
struct NonPod { ~NonPod(); };
void f(...);
void g(NonPod np) { f(np); } // expected-error {{cannot pass}}
}
// FIXME: Add tests here once DR260 is resolved.
// dr507: dup 260
// dr508: na
// dr509: na
// dr510: na
namespace dr512 { // dr512: yes
struct A {
A(int);
};
union U { A a; };
#if __cplusplus < 201103L
// expected-error@-2 {{has a non-trivial constructor}}
// expected-note@-6 {{no default constructor}}
// expected-note@-6 {{suppressed by user-declared constructor}}
#endif
}
// dr513: na
namespace dr514 { // dr514: yes
namespace A { extern int x, y; }
int A::x = y;
}
namespace dr515 { // dr515: sup 1017
// FIXME: dr1017 reverses the wording of dr515, but the current draft has
// dr515's wording, with a different fix for dr1017.
struct X { int n; };
template<typename T> struct Y : T {
int f() { return X::n; }
};
int k = Y<X>().f();
struct A { int a; };
struct B { void f() { int k = sizeof(A::a); } };
#if __cplusplus < 201103L
// expected-error@-2 {{invalid use of non-static data member}}
#endif
}
// dr516: na
namespace dr517 { // dr517: no
// This is NDR, but we should diagnose it anyway.
template<typename T> struct S {};
template<typename T> int v = 0; // expected-error 0-1{{extension}}
template struct S<int*>;
template int v<int*>;
S<char&> s;
int k = v<char&>;
// FIXME: These are both ill-formed.
template<typename T> struct S<T*> {};
template<typename T> int v<T*> = 0; // expected-error 0-1{{extension}}
// FIXME: These are both ill-formed.
template<typename T> struct S<T&> {};
template<typename T> int v<T&> = 0; // expected-error 0-1{{extension}}
}
namespace dr518 { // dr518: yes c++11
enum E { e, };
#if __cplusplus < 201103L
// expected-error@-2 {{C++11 extension}}
#endif
}
namespace dr519 { // dr519: yes
// FIXME: Add a codegen test.
#if __cplusplus >= 201103L
#define fold(x) (__builtin_constant_p(x) ? (x) : (x))
int test[fold((int*)(void*)0) ? -1 : 1];
#undef fold
#endif
}
// dr520: na
// dr521: no
// FIXME: The wording here is broken. It's not reasonable to expect a
// diagnostic here. Once the relevant DR gets a number, mark this as a dup.
namespace dr522 { // dr522: yes
struct S {};
template<typename T> void b1(volatile T &);
template<typename T> void b2(volatile T * const *);
template<typename T> void b2(volatile T * const S::*);
template<typename T> void b2(volatile T * const S::* const *);
// FIXME: This diagnostic isn't very good. The problem is not substitution failure.
template<typename T> void b2a(volatile T *S::* const *); // expected-note {{substitution failure}}
template<typename T> struct Base {};
struct Derived : Base<int> {};
template<typename T> void b3(Base<T>);
template<typename T> void b3(Base<T> *);
void test(int n, const int cn, int **p, int *S::*pm) {
int *a[3], *S::*am[3];
const Derived cd = Derived();
Derived d[3];
b1(n);
b1(cn);
b2(p);
b2(pm);
b2(a);
b2(am);
b2a(am); // expected-error {{no matching function}}
b3(d);
b3(cd);
}
}
namespace dr524 { // dr524: yes
template<typename T> void f(T a, T b) { operator+(a, b); } // expected-error {{call}}
struct S {};
void operator+(S, S);
template void f(S, S);
namespace N { struct S {}; }
void operator+(N::S, N::S); // expected-note {{should be declared}}
template void f(N::S, N::S); // expected-note {{instantiation}}
}
namespace dr525 { // dr525: yes
namespace before {
// Note, the example was correct prior to the change; instantiation is
// required for cases like this:
template <class T> struct D { operator T*(); };
void g(D<double> ppp) {
delete ppp;
}
}
namespace after {
template <class T> struct D { typename T::error e; }; // expected-error {{prior to '::'}}
void g(D<double> *ppp) {
delete ppp; // expected-note {{instantiation of}}
}
}
}
namespace dr526 { // dr526: yes
template<int> struct S {};
template<int N> void f1(S<N> s);
template<int N> void f2(S<(N)> s); // expected-note {{couldn't infer}}
template<int N> void f3(S<+N> s); // expected-note {{couldn't infer}}
template<int N> void g1(int (&)[N]);
template<int N> void g2(int (&)[(N)]); // expected-note {{couldn't infer}}
template<int N> void g3(int (&)[+N]); // expected-note {{couldn't infer}}
void test(int (&a)[3], S<3> s) {
f1(s);
f2(s); // expected-error {{no matching}}
f3(s); // expected-error {{no matching}}
g1(a);
g2(a); // expected-error {{no matching}}
g3(a); // expected-error {{no matching}}
}
template<int N> struct X {
typedef int type;
X<N>::type v1;
X<(N)>::type v2; // expected-error {{missing 'typename'}}
X<+N>::type v3; // expected-error {{missing 'typename'}}
};
}
namespace dr527 { // dr527: na
// This DR is meaningless. It removes a required diagnostic from the case
// where a not-externally-visible object is odr-used but not defined, which
// requires a diagnostic for a different reason.
extern struct { int x; } a; // FIXME: We should reject this, per dr389.
static struct { int x; } b;
extern "C" struct { int x; } c;
namespace { extern struct { int x; } d; }
typedef struct { int x; } *P;
struct E { static P e; }; // FIXME: We should reject this, per dr389.
namespace { struct F { static P f; }; }
int ax = a.x, bx = b.x, cx = c.x, dx = d.x, ex = E::e->x, fx = F::f->x;
}
namespace dr530 { // dr530: yes
template<int*> struct S { enum { N = 1 }; };
template<void(*)()> struct T { enum { N = 1 }; };
int n;
void f();
int a[S<&n>::N];
int b[T<&f>::N];
}
namespace dr531 { // dr531: partial
namespace good {
template<typename T> struct A {
void f(T) { T::error; }
template<typename U> void g(T, U) { T::error; }
struct B { typename T::error error; };
template<typename U> struct C { typename T::error error; };
static T n;
};
template<typename T> T A<T>::n = T::error;
template<> void A<int>::f(int) {}
template<> template<typename U> void A<int>::g(int, U) {}
template<> struct A<int>::B {};
template<> template<typename U> struct A<int>::C {};
template<> int A<int>::n = 0;
void use(A<int> a) {
a.f(a.n);
a.g(0, 0);
A<int>::B b;
A<int>::C<int> c;
}
template<> struct A<char> {
void f(char);
template<typename U> void g(char, U);
struct B;
template<typename U> struct C;
static char n;
};
void A<char>::f(char) {}
template<typename U> void A<char>::g(char, U) {}
struct A<char>::B {};
template<typename U> struct A<char>::C {};
char A<char>::n = 0;
}
namespace bad {
template<typename T> struct A {
void f(T) { T::error; }
template<typename U> void g(T, U) { T::error; }
struct B { typename T::error error; };
template<typename U> struct C { typename T::error error; }; // expected-note {{here}}
static T n;
};
template<typename T> T A<T>::n = T::error;
void A<int>::f(int) {} // expected-error {{requires 'template<>'}}
template<typename U> void A<int>::g(int, U) {} // expected-error {{should be empty}}
struct A<int>::B {}; // expected-error {{requires 'template<>'}}
template<typename U> struct A<int>::C {}; // expected-error {{should be empty}} expected-error {{different kind of symbol}}
int A<int>::n = 0; // expected-error {{requires 'template<>'}}
template<> struct A<char> { // expected-note 2{{here}}
void f(char);
template<typename U> void g(char, U);
struct B; // expected-note {{here}}
template<typename U> struct C;
static char n;
};
template<> void A<char>::f(char) {} // expected-error {{no function template matches}}
// FIXME: This is ill-formed; -pedantic-errors should reject.
template<> template<typename U> void A<char>::g(char, U) {} // expected-warning {{extraneous template parameter list}}
template<> struct A<char>::B {}; // expected-error {{extraneous 'template<>'}} expected-error {{does not specialize}}
// FIXME: This is ill-formed; -pedantic-errors should reject.
template<> template<typename U> struct A<char>::C {}; // expected-warning {{extraneous template parameter list}}
template<> char A<char>::n = 0; // expected-error {{extraneous 'template<>'}}
}
namespace nested {
template<typename T> struct A {
template<typename U> struct B;
};
template<> template<typename U> struct A<int>::B {
void f();
void g();
template<typename V> void h();
template<typename V> void i();
};
template<> template<typename U> void A<int>::B<U>::f() {}
template<typename U> void A<int>::B<U>::g() {} // expected-error {{should be empty}}
template<> template<typename U> template<typename V> void A<int>::B<U>::h() {}
template<typename U> template<typename V> void A<int>::B<U>::i() {} // expected-error {{should be empty}}
template<> template<> void A<int>::B<int>::f() {}
template<> template<> template<typename V> void A<int>::B<int>::h() {}
template<> template<> template<> void A<int>::B<int>::h<int>() {}
template<> void A<int>::B<char>::f() {} // expected-error {{requires 'template<>'}}
template<> template<typename V> void A<int>::B<char>::h() {} // expected-error {{should be empty}}
}
}
// PR8130
namespace dr532 { // dr532: 3.5
struct A { };
template<class T> struct B {
template<class R> int &operator*(R&);
};
template<class T, class R> float &operator*(T&, R&);
void test() {
A a;
B<A> b;
int &ir = b * a;
}
}
// dr533: na
namespace dr534 { // dr534: yes
struct S {};
template<typename T> void operator+(S, T);
template<typename T> void operator+<T*>(S, T*) {} // expected-error {{function template partial spec}}
}
namespace dr535 { // dr535: yes
class X { private: X(const X&); };
struct A {
X x;
template<typename T> A(T&);
};
struct B : A {
X y;
B(volatile A&);
};
extern A a1;
A a2(a1); // ok, uses constructor template
extern volatile B b1;
B b2(b1); // ok, uses converting constructor
void f() { throw a1; }
#if __cplusplus >= 201103L
struct C {
constexpr C() : n(0) {}
template<typename T> constexpr C(T&t) : n(t.n == 0 ? throw 0 : 0) {}
int n;
};
constexpr C c() { return C(); }
// ok, copy is elided
constexpr C x = c();
#endif
}
// dr537: na
// dr538: na
// dr539: yes
const dr539( // expected-error {{requires a type specifier}}
const a) { // expected-error {{unknown type name 'a'}}
const b; // expected-error {{requires a type specifier}}
new const; // expected-error {{expected a type}}
try {} catch (const n) {} // expected-error {{unknown type name 'n'}}
try {} catch (const) {} // expected-error {{expected a type}}
if (const n = 0) {} // expected-error {{requires a type specifier}}
switch (const n = 0) {} // expected-error {{requires a type specifier}}
while (const n = 0) {} // expected-error {{requires a type specifier}}
for (const n = 0; // expected-error {{requires a type specifier}}
const m = 0; ) {} // expected-error {{requires a type specifier}}
sizeof(const); // expected-error {{requires a type specifier}}
struct S {
const n; // expected-error {{requires a type specifier}}
operator const(); // expected-error {{expected a type}}
};
#if __cplusplus >= 201103L
int arr[3];
// FIXME: The extra braces here are to avoid the parser getting too
// badly confused when recovering here. We should fix this recovery.
{ for (const n // expected-error {{unknown type name 'n'}} expected-note {{}}
: arr) ; {} } // expected-error +{{}}
(void) [](const) {}; // expected-error {{requires a type specifier}}
(void) [](const n) {}; // expected-error {{unknown type name 'n'}}
enum E : const {}; // expected-error {{expected a type}}
using T = const; // expected-error {{expected a type}}
auto f() -> const; // expected-error {{expected a type}}
#endif
}
namespace dr540 { // dr540: yes
typedef int &a;
typedef const a &a; // expected-warning {{has no effect}}
typedef const int &b;
typedef b &b;
typedef const a &c; // expected-note {{previous}} expected-warning {{has no effect}}
typedef const b &c; // expected-error {{different}} expected-warning {{has no effect}}
}
namespace dr541 { // dr541: yes
template<int> struct X { typedef int type; };
template<typename T> struct S {
int f(T);
int g(int);
T g(bool);
int h();
int h(T);
void x() {
// These are type-dependent expressions, even though we could
// determine that all calls have type 'int'.
X<sizeof(f(0))>::type a; // expected-error +{{}}
X<sizeof(g(0))>::type b; // expected-error +{{}}
X<sizeof(h(0))>::type b; // expected-error +{{}}
typename X<sizeof(f(0))>::type a;
typename X<sizeof(h(0))>::type b;
}
};
}
namespace dr542 { // dr542: yes
#if __cplusplus >= 201103L
struct A { A() = delete; int n; };
A a[32] = {}; // ok, constructor not called
struct B {
int n;
private:
B() = default;
};
B b[32] = {}; // ok, constructor not called
#endif
}
namespace dr543 { // dr543: yes
// In C++98+DR543, this is valid because value-initialization doesn't call a
// trivial default constructor, so we never notice that defining the
// constructor would be ill-formed.
//
// In C++11+DR543, this is ill-formed, because the default constructor is
// deleted, and value-initialization *does* call a deleted default
// constructor, even if it is trivial.
struct A {
const int n;
};
A a = A();
#if __cplusplus >= 201103L
// expected-error@-2 {{deleted}}
// expected-note@-5 {{would not be initialized}}
#endif
}
namespace dr544 { // dr544: yes
int *n;
template<class T> struct A { int n; };
template<class T> struct B : A<T> { int get(); };
template<> int B<int>::get() { return n; }
int k = B<int>().get();
}
namespace dr546 { // dr546: yes
template<typename T> struct A { void f(); };
template struct A<int>;
template<typename T> void A<T>::f() { T::error; }
}
namespace dr547 { // dr547: yes
// When targeting the MS x86 ABI, the type of a member function includes a
// __thiscall qualifier. This is non-conforming, but we still implement
// the intent of dr547
#if defined(_M_IX86) || (defined(__MINGW32__) && !defined(__MINGW64__))
#define THISCALL __thiscall
#else
#define THISCALL
#endif
template<typename T> struct X;
template<typename T> struct X<THISCALL T() const> {};
template<typename T, typename C> X<T> f(T C::*) { return X<T>(); }
struct S { void f() const; };
X<THISCALL void() const> x = f(&S::f);
#undef THISCALL
}
namespace dr548 { // dr548: dup 482
template<typename T> struct S {};
template<typename T> void f() {}
template struct dr548::S<int>;
template void dr548::f<int>();
}
namespace dr551 { // dr551: yes c++11
// FIXME: This obviously should apply in C++98 mode too.
template<typename T> void f() {}
template inline void f<int>();
#if __cplusplus >= 201103L
// expected-error@-2 {{cannot be 'inline'}}
#endif
template<typename T> inline void g() {}
template inline void g<int>();
#if __cplusplus >= 201103L
// expected-error@-2 {{cannot be 'inline'}}
#endif
template<typename T> struct X {
void f() {}
};
template inline void X<int>::f();
#if __cplusplus >= 201103L
// expected-error@-2 {{cannot be 'inline'}}
#endif
}
namespace dr552 { // dr552: yes
template<typename T, typename T::U> struct X {};
struct Y { typedef int U; };
X<Y, 0> x;
}
struct dr553_class {
friend void *operator new(size_t, dr553_class);
};
namespace dr553 {
dr553_class c;
// Contrary to the apparent intention of the DR, operator new is not actually
// looked up with a lookup mechanism that performs ADL; the standard says it
// "is looked up in global scope", where it is not visible.
void *p = new (c) int; // expected-error {{no matching function}}
struct namespace_scope {
friend void *operator new(size_t, namespace_scope); // expected-error {{cannot be declared inside a namespace}}
};
}
// dr556: na
namespace dr557 { // dr557: yes
template<typename T> struct S {
friend void f(S<T> *);
friend void g(S<S<T> > *);
};
void x(S<int> *p, S<S<int> > *q) {
f(p);
g(q);
}
}
namespace dr558 { // dr558: yes
wchar_t a = L'\uD7FF';
wchar_t b = L'\xD7FF';
wchar_t c = L'\uD800'; // expected-error {{invalid universal character}}
wchar_t d = L'\xD800';
wchar_t e = L'\uDFFF'; // expected-error {{invalid universal character}}
wchar_t f = L'\xDFFF';
wchar_t g = L'\uE000';
wchar_t h = L'\xE000';
}
template<typename> struct dr559 { typedef int T; dr559::T u; }; // dr559: yes
namespace dr561 { // dr561: yes
template<typename T> void f(int);
template<typename T> void g(T t) {
f<T>(t);
}
namespace {
struct S {};
template<typename T> static void f(S);
}
void h(S s) {
g(s);
}
}
namespace dr564 { // dr564: yes
extern "C++" void f(int);
void f(int); // ok
extern "C++" { extern int n; }
int n; // ok
}
namespace dr565 { // dr565: yes
namespace N {
template<typename T> int f(T); // expected-note {{target}}
}
using N::f; // expected-note {{using}}
template<typename T> int f(T*);
template<typename T> void f(T);
template<typename T, int = 0> int f(T); // expected-error 0-1{{extension}}
template<typename T> int f(T, int = 0);
template<typename T> int f(T); // expected-error {{conflicts with}}
}
namespace dr566 { // dr566: yes
#if __cplusplus >= 201103L
int check[int(-3.99) == -3 ? 1 : -1];
#endif
}
// dr567: na
namespace dr568 { // dr568: yes c++11
// FIXME: This is a DR issue against C++98, so should probably apply there
// too.
struct x { int y; };
class trivial : x {
x y;
public:
int n;
};
int check_trivial[__is_trivial(trivial) ? 1 : -1];
struct std_layout {
std_layout();
std_layout(const std_layout &);
~std_layout();
private:
int n;
};
int check_std_layout[__is_standard_layout(std_layout) ? 1 : -1];
struct aggregate {
int x;
int y;
trivial t;
std_layout sl;
};
aggregate aggr = {};
void f(...);
void g(trivial t) { f(t); }
#if __cplusplus < 201103L
// expected-error@-2 {{non-POD}}
#endif
void jump() {
goto x;
#if __cplusplus < 201103L
// expected-error@-2 {{cannot jump}}
// expected-note@+2 {{non-POD}}
#endif
trivial t;
x: ;
}
}
namespace dr569 { // dr569: yes c++11
// FIXME: This is a DR issue against C++98, so should probably apply there
// too.
;;;;;
#if __cplusplus < 201103L
// expected-error@-2 {{C++11 extension}}
#endif
}
namespace dr570 { // dr570: dup 633
int n;
int &r = n; // expected-note {{previous}}
int &r = n; // expected-error {{redefinition}}
}
namespace dr571 { // dr571 unknown
// FIXME: Add a codegen test.
typedef int &ir;
int n;
const ir r = n; // expected-warning {{has no effect}} FIXME: Test if this has internal linkage.
}
namespace dr572 { // dr572: yes
enum E { a = 1, b = 2 };
int check[a + b == 3 ? 1 : -1];
}
namespace dr573 { // dr573: no
void *a;
int *b = reinterpret_cast<int*>(a);
void (*c)() = reinterpret_cast<void(*)()>(a);
void *d = reinterpret_cast<void*>(c);
#if __cplusplus < 201103L
// expected-error@-3 {{extension}}
// expected-error@-3 {{extension}}
#endif
void f() { delete a; } // expected-error {{cannot delete}}
int n = d - a; // expected-error {{arithmetic on pointers to void}}
// FIXME: This is ill-formed.
template<void*> struct S;
template<int*> struct T;
}
namespace dr574 { // dr574: yes
struct A {
A &operator=(const A&) const; // expected-note {{does not match because it is const}}
};
struct B {
B &operator=(const B&) volatile; // expected-note {{nearly matches}}
};
#if __cplusplus >= 201103L
struct C {
C &operator=(const C&) &; // expected-note {{not viable}} expected-note {{nearly matches}} expected-note {{here}}
};
struct D {
D &operator=(const D&) &&; // expected-note {{not viable}} expected-note {{nearly matches}} expected-note {{here}}
};
void test(C c, D d) {
c = c;
C() = c; // expected-error {{no viable}}
d = d; // expected-error {{no viable}}
D() = d;
}
#endif
struct Test {
friend A &A::operator=(const A&); // expected-error {{does not match}}
friend B &B::operator=(const B&); // expected-error {{does not match}}
#if __cplusplus >= 201103L
// FIXME: We shouldn't produce the 'cannot overload' diagnostics here.
friend C &C::operator=(const C&); // expected-error {{does not match}} expected-error {{cannot overload}}
friend D &D::operator=(const D&); // expected-error {{does not match}} expected-error {{cannot overload}}
#endif
};
}
namespace dr575 { // dr575: yes
template<typename T, typename U = typename T::type> void a(T); void a(...); // expected-error 0-1{{extension}}
template<typename T, typename T::type U = 0> void b(T); void b(...); // expected-error 0-1{{extension}}
template<typename T, int U = T::value> void c(T); void c(...); // expected-error 0-1{{extension}}
template<typename T> void d(T, int = T::value); void d(...); // expected-error {{cannot be used prior to '::'}}
void x() {
a(0);
b(0);
c(0);
d(0); // expected-note {{in instantiation of default function argument}}
}
template<typename T = int&> void f(T* = 0); // expected-error 0-1{{extension}}
template<typename T = int> void f(T = 0); // expected-error 0-1{{extension}}
void g() { f<>(); }
template<typename T> T &h(T *);
template<typename T> T *h(T *);
void *p = h((void*)0);
}
namespace dr576 { // dr576: yes
typedef void f() {} // expected-error {{function definition declared 'typedef'}}
void f(typedef int n); // expected-error {{invalid storage class}}
void f(char c) { typedef int n; }
}
namespace dr577 { // dr577: yes
typedef void V;
typedef const void CV;
void a(void);
void b(const void); // expected-error {{qualifiers}}
void c(V);
void d(CV); // expected-error {{qualifiers}}
void (*e)(void) = c;
void (*f)(const void); // expected-error {{qualifiers}}
void (*g)(V) = a;
void (*h)(CV); // expected-error {{qualifiers}}
template<typename T> void i(T); // expected-note 2{{requires 1 arg}}
template<typename T> void j(void (*)(T)); // expected-note 2{{argument may not have 'void' type}}
void k() {
a();
c();
i<void>(); // expected-error {{no match}}
i<const void>(); // expected-error {{no match}}
j<void>(0); // expected-error {{no match}}
j<const void>(0); // expected-error {{no match}}
}
}
namespace dr580 { // dr580: no
class C;
struct A { static C c; };
struct B { static C c; };
class C {
C(); // expected-note {{here}}
~C(); // expected-note {{here}}
typedef int I; // expected-note {{here}}
template<int> struct X;
template<int> friend struct Y;
template<int> void f();
template<int> friend void g();
friend struct A;
};
template<C::I> struct C::X {};
template<C::I> struct Y {};
template<C::I> struct Z {}; // FIXME: should reject, accepted because C befriends A!
template<C::I> void C::f() {}
template<C::I> void g() {}
template<C::I> void h() {} // expected-error {{private}}
C A::c;
C B::c; // expected-error 2{{private}}
}
// dr582: na
namespace dr583 { // dr583: no
// see n3624
int *p;
// FIXME: These are all ill-formed.
bool b1 = p < 0;
bool b2 = p > 0;
bool b3 = p <= 0;
bool b4 = p >= 0;
}
// dr584: na
namespace dr585 { // dr585: yes
template<typename> struct T;
struct A {
friend T; // expected-error {{requires a type specifier}} expected-error {{can only be classes or functions}}
// FIXME: It's not clear whether the standard allows this or what it means,
// but the DR585 writeup suggests it as an alternative.
template<typename U> friend T<U>; // expected-error {{must use an elaborated type}}
};
template<template<typename> class T> struct B {
friend T; // expected-error {{requires a type specifier}} expected-error {{can only be classes or functions}}
template<typename U> friend T<U>; // expected-error {{must use an elaborated type}}
};
}
// dr586: na
namespace dr587 { // dr587: yes
template<typename T> void f(bool b, const T x, T y) {
const T *p = &(b ? x : y);
}
struct S {};
template void f(bool, const int, int);
template void f(bool, const S, S);
}
namespace dr588 { // dr588: yes
struct A { int n; }; // expected-note {{ambiguous}}
template<typename T> int f() {
struct S : A, T { int f() { return n; } } s;
int a = s.f();
int b = s.n; // expected-error {{found in multiple}}
}
struct B { int n; }; // expected-note {{ambiguous}}
int k = f<B>(); // expected-note {{here}}
}
namespace dr589 { // dr589: yes
struct B { };
struct D : B { };
D f();
extern const B &b;
bool a;
const B *p = &(a ? f() : b); // expected-error {{temporary}}
const B *q = &(a ? D() : b); // expected-error {{temporary}}
}
namespace dr590 { // dr590: yes
template<typename T> struct A {
struct B {
struct C {
A<T>::B::C f(A<T>::B::C); // ok, no 'typename' required.
};
};
};
template<typename T> typename A<T>::B::C A<T>::B::C::f(A<T>::B::C) {}
}
namespace dr591 { // dr591: no
template<typename T> struct A {
typedef int M;
struct B {
typedef void M;
struct C;
};
};
template<typename T> struct A<T>::B::C : A<T> {
// FIXME: Should find member of non-dependent base class A<T>.
M m; // expected-error {{incomplete type 'M' (aka 'void'}}
};
}
// dr592: na
// dr593 needs an IRGen test.
// dr594: na
namespace dr595 { // dr595: dup 1330
template<class T> struct X {
void f() throw(T) {}
};
struct S {
X<S> xs;
};
}
// dr597: na
namespace dr598 { // dr598: yes
namespace N {
void f(int);
void f(char);
// Not found by ADL.
void g(void (*)(int));
void h(void (*)(int));
namespace M {
struct S {};
int &h(void (*)(S));
}
void i(M::S);
void i();
}
int &g(void(*)(char));
int &r = g(N::f);
int &s = h(N::f); // expected-error {{undeclared}}
int &t = h(N::i);
}
namespace dr599 { // dr599: partial
typedef int Fn();
struct S { operator void*(); };
struct T { operator Fn*(); };
struct U { operator int*(); operator void*(); }; // expected-note 2{{conversion}}
struct V { operator int*(); operator Fn*(); };
void f(void *p, void (*q)(), S s, T t, U u, V v) {
delete p; // expected-error {{cannot delete}}
delete q; // expected-error {{cannot delete}}
delete s; // expected-error {{cannot delete}}
delete t; // expected-error {{cannot delete}}
// FIXME: This is valid, but is rejected due to a non-conforming GNU
// extension allowing deletion of pointers to void.
delete u; // expected-error {{ambiguous}}
delete v;
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr13xx.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
namespace dr1346 { // dr1346: 3.5
auto a(1); // expected-error 0-1{{extension}}
auto b(1, 2); // expected-error {{multiple expressions}} expected-error 0-1{{extension}}
#if __cplusplus >= 201103L
auto c({}); // expected-error {{parenthesized initializer list}} expected-error {{cannot deduce}}
auto d({1}); // expected-error {{parenthesized initializer list}} expected-error {{<initializer_list>}}
auto e({1, 2}); // expected-error {{parenthesized initializer list}} expected-error {{<initializer_list>}}
#endif
template<typename...Ts> void f(Ts ...ts) { // expected-error 0-1{{extension}}
auto x(ts...); // expected-error {{empty}} expected-error 0-1{{extension}}
}
template void f(); // expected-note {{instantiation}}
#if __cplusplus >= 201103L
void init_capture() {
[a(1)] {} (); // expected-error 0-1{{extension}}
[b(1, 2)] {} (); // expected-error {{multiple expressions}} expected-error 0-1{{extension}}
#if __cplusplus >= 201103L
[c({})] {} (); // expected-error {{parenthesized initializer list}} expected-error {{cannot deduce}} expected-error 0-1{{extension}}
[d({1})] {} (); // expected-error {{parenthesized initializer list}} expected-error {{<initializer_list>}} expected-error 0-1{{extension}}
[e({1, 2})] {} (); // expected-error {{parenthesized initializer list}} expected-error {{<initializer_list>}} expected-error 0-1{{extension}}
#endif
}
#endif
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/drs/dr7xx.cpp
|
// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
namespace dr777 { // dr777: 3.7
#if __cplusplus >= 201103L
template <typename... T>
void f(int i = 0, T ...args) {}
void ff() { f(); }
template <typename... T>
void g(int i = 0, T ...args, T ...args2) {}
template <typename... T>
void h(int i = 0, T ...args, int j = 1) {}
#endif
}
// expected-no-diagnostics
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/p4.cpp
|
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
// C++0x [class.access]p4:
// Access control is applied uniformly to all names, whether the
// names are referred to from declarations or expressions. In the
// case of overloaded function names, access control is applied to
// the function selected by overload resolution.
class Public {} PublicInst;
class Protected {} ProtectedInst;
class Private {} PrivateInst;
namespace test0 {
class A {
public:
void foo(Public&);
protected:
void foo(Protected&); // expected-note 2 {{declared protected here}}
private:
void foo(Private&); // expected-note 2 {{declared private here}}
};
void test(A *op) {
op->foo(PublicInst);
op->foo(ProtectedInst); // expected-error {{'foo' is a protected member}}
op->foo(PrivateInst); // expected-error {{'foo' is a private member}}
void (A::*a)(Public&) = &A::foo;
void (A::*b)(Protected&) = &A::foo; // expected-error {{'foo' is a protected member}}
void (A::*c)(Private&) = &A::foo; // expected-error {{'foo' is a private member}}
}
}
// Member operators.
namespace test1 {
class A {
public:
void operator+(Public&);
void operator[](Public&);
void operator()(Public&);
typedef void (*PublicSurrogate)(Public&);
operator PublicSurrogate() const;
protected:
void operator+(Protected&); // expected-note {{declared protected here}}
void operator[](Protected&); // expected-note {{declared protected here}}
void operator()(Protected&); // expected-note {{declared protected here}}
typedef void (*ProtectedSurrogate)(Protected&);
operator ProtectedSurrogate() const; // expected-note {{declared protected here}}
private:
void operator+(Private&); // expected-note {{declared private here}}
void operator[](Private&); // expected-note {{declared private here}}
void operator()(Private&); // expected-note {{declared private here}}
void operator-(); // expected-note {{declared private here}}
typedef void (*PrivateSurrogate)(Private&);
operator PrivateSurrogate() const; // expected-note {{declared private here}}
};
void operator+(const A &, Public&);
void operator+(const A &, Protected&);
void operator+(const A &, Private&);
void operator-(const A &);
void test(A &a, Public &pub, Protected &prot, Private &priv) {
a + pub;
a + prot; // expected-error {{'operator+' is a protected member}}
a + priv; // expected-error {{'operator+' is a private member}}
a[pub];
a[prot]; // expected-error {{'operator[]' is a protected member}}
a[priv]; // expected-error {{'operator[]' is a private member}}
a(pub);
a(prot); // expected-error {{'operator()' is a protected member}}
a(priv); // expected-error {{'operator()' is a private member}}
-a; // expected-error {{'operator-' is a private member}}
const A &ca = a;
ca + pub;
ca + prot;
ca + priv;
-ca;
// These are all surrogate calls
ca(pub);
ca(prot); // expected-error {{'operator void (*)(Protected &)' is a protected member}}
ca(priv); // expected-error {{'operator void (*)(Private &)' is a private member}}
}
}
// Implicit constructor calls.
namespace test2 {
class A {
private:
A(); // expected-note 3 {{declared private here}}
static A foo;
};
A a; // expected-error {{calling a private constructor}}
A A::foo; // okay
class B : A { }; // expected-error {{base class 'test2::A' has private default constructor}}
B b; // expected-note{{implicit default constructor}}
class C : virtual A {
public:
C();
};
class D : C { }; // expected-error {{inherited virtual base class 'test2::A' has private default constructor}}
D d; // expected-note{{implicit default constructor}}
}
// Implicit destructor calls.
namespace test3 {
class A {
private:
~A(); // expected-note 2 {{declared private here}}
static A foo;
};
A a; // expected-error {{variable of type 'test3::A' has private destructor}}
A A::foo;
void foo(A param) { // okay
A local; // expected-error {{variable of type 'test3::A' has private destructor}}
}
template <unsigned N> class Base { ~Base(); }; // expected-note 14 {{declared private here}}
class Base2 : virtual Base<2> { ~Base2(); }; // expected-note 3 {{declared private here}} \
// expected-error {{base class 'Base<2>' has private destructor}}
class Base3 : virtual Base<3> { public: ~Base3(); }; // expected-error {{base class 'Base<3>' has private destructor}}
// These don't cause diagnostics because we don't need the destructor.
class Derived0 : Base<0> { ~Derived0(); };
class Derived1 : Base<1> { };
class Derived2 : // expected-error {{inherited virtual base class 'Base<2>' has private destructor}} \
// expected-error {{inherited virtual base class 'Base<3>' has private destructor}}
Base<0>, // expected-error {{base class 'Base<0>' has private destructor}}
virtual Base<1>, // expected-error {{base class 'Base<1>' has private destructor}}
Base2, // expected-error {{base class 'test3::Base2' has private destructor}}
virtual Base3
{
~Derived2() {}
};
class Derived3 : // expected-error 2 {{inherited virtual base class 'Base<2>' has private destructor}} \
// expected-error 2 {{inherited virtual base class 'Base<3>' has private destructor}} \
// expected-note 2{{implicit default constructor}}
Base<0>, // expected-error 2 {{base class 'Base<0>' has private destructor}}
virtual Base<1>, // expected-error 2 {{base class 'Base<1>' has private destructor}}
Base2, // expected-error 2 {{base class 'test3::Base2' has private destructor}}
virtual Base3
{};
Derived3 d3; // expected-note {{implicit default constructor}}\
// expected-note{{implicit destructor}}}
}
// Conversion functions.
namespace test4 {
class Base {
private:
operator Private(); // expected-note 4 {{declared private here}}
public:
operator Public(); // expected-note 2{{member is declared here}}
};
class Derived1 : private Base { // expected-note 2 {{declared private here}} \
// expected-note {{constrained by private inheritance}}
Private test1() { return *this; } // expected-error {{'operator Private' is a private member}}
Public test2() { return *this; }
};
Private test1(Derived1 &d) { return d; } // expected-error {{'operator Private' is a private member}} \
// expected-error {{cannot cast 'test4::Derived1' to its private base class}}
Public test2(Derived1 &d) { return d; } // expected-error {{cannot cast 'test4::Derived1' to its private base class}} \
// expected-error {{'operator Public' is a private member}}
class Derived2 : public Base {
Private test1() { return *this; } // expected-error {{'operator Private' is a private member}}
Public test2() { return *this; }
};
Private test1(Derived2 &d) { return d; } // expected-error {{'operator Private' is a private member}}
Public test2(Derived2 &d) { return d; }
class Derived3 : private Base { // expected-note {{constrained by private inheritance here}} \
// expected-note {{declared private here}}
public:
operator Private();
};
Private test1(Derived3 &d) { return d; }
Public test2(Derived3 &d) { return d; } // expected-error {{'operator Public' is a private member of 'test4::Base'}} \
// expected-error {{cannot cast 'test4::Derived3' to its private base class}}
class Derived4 : public Base {
public:
operator Private();
};
Private test1(Derived4 &d) { return d; }
Public test2(Derived4 &d) { return d; }
}
// Implicit copy assignment operator uses.
namespace test5 {
class A {
void operator=(const A &); // expected-note 2 {{implicitly declared private here}}
};
class Test1 { A a; }; // expected-error {{private member}}
void test1() {
Test1 a;
a = Test1(); // expected-note{{implicit copy}}
}
class Test2 : A {}; // expected-error {{private member}}
void test2() {
Test2 a;
a = Test2(); // expected-note{{implicit copy}}
}
}
// Implicit copy constructor uses.
namespace test6 {
class A {
public: A();
private: A(const A &); // expected-note 2 {{declared private here}}
};
class Test1 { A a; }; // expected-error {{field of type 'test6::A' has private copy constructor}}
void test1(const Test1 &t) {
Test1 a = t; // expected-note{{implicit copy}}
}
class Test2 : A {}; // expected-error {{base class 'test6::A' has private copy constructor}}
void test2(const Test2 &t) {
Test2 a = t; // expected-note{{implicit copy}}
}
}
// Redeclaration lookups are not accesses.
namespace test7 {
class A {
int private_member;
};
class B : A {
int foo(int private_member) {
return 0;
}
};
}
// Ignored operator new and delete overloads are not
namespace test8 {
typedef __typeof__(sizeof(int)) size_t;
class A {
void *operator new(size_t s);
void operator delete(void *p);
public:
void *operator new(size_t s, int n);
void operator delete(void *p, int n);
};
void test() {
new (2) A();
}
}
// Don't silently upgrade forbidden-access paths to private.
namespace test9 {
class A {
public: static int x; // expected-note {{member is declared here}}
};
class B : private A { // expected-note {{constrained by private inheritance here}}
};
class C : public B {
static int getX() { return x; } // expected-error {{'x' is a private member of 'test9::A'}}
};
}
namespace test10 {
class A {
enum {
value = 10 // expected-note {{declared private here}}
};
friend class C;
};
class B {
enum {
value = A::value // expected-error {{'value' is a private member of 'test10::A'}}
};
};
class C {
enum {
value = A::value
};
};
}
namespace test11 {
class A {
protected: virtual ~A();
};
class B : public A {
~B();
};
B::~B() {};
}
namespace test12 {
class A {
int x;
void foo() {
class Local {
int foo(A *a) {
return a->x;
}
};
}
};
}
namespace test13 {
struct A {
int x;
unsigned foo() const;
};
struct B : protected A {
using A::foo;
using A::x;
};
void test() {
A *d;
d->foo();
(void) d->x;
}
}
// Destructors for temporaries.
namespace test14 {
class A {
private: ~A(); // expected-note {{declared private here}}
};
A foo();
void test() {
foo(); // expected-error {{temporary of type 'test14::A' has private destructor}}
}
class X {
~X(); // expected-note {{declared private here}}
};
struct Y1 {
operator X();
};
void g() {
const X &xr = Y1(); // expected-error{{temporary of type 'test14::X' has private destructor}}
}
}
// PR 7024
namespace test15 {
template <class T> class A {
private:
int private_foo; // expected-note {{declared private here}}
static int private_sfoo; // expected-note {{declared private here}}
protected:
int protected_foo; // expected-note 3 {{declared protected here}} // expected-note {{can only access this member on an object of type 'test15::B<int>'}}
static int protected_sfoo; // expected-note 3 {{declared protected here}}
int test1(A<int> &a) {
return a.private_foo; // expected-error {{private member}}
}
int test2(A<int> &a) {
return a.private_sfoo; // expected-error {{private member}}
}
int test3(A<int> &a) {
return a.protected_foo; // expected-error {{protected member}}
}
int test4(A<int> &a) {
return a.protected_sfoo; // expected-error {{protected member}}
}
};
template class A<int>;
template class A<long>; // expected-note 4 {{in instantiation}}
template <class T> class B : public A<T> {
// TODO: These first two accesses can be detected as ill-formed at
// definition time because they're member accesses and A<int> can't
// be a subclass of B<T> for any T.
int test1(A<int> &a) {
return a.protected_foo; // expected-error 2 {{protected member}}
}
int test2(A<int> &a) {
return a.protected_sfoo; // expected-error {{protected member}}
}
int test3(B<int> &b) {
return b.protected_foo; // expected-error {{protected member}}
}
int test4(B<int> &b) {
return b.protected_sfoo; // expected-error {{protected member}}
}
};
template class B<int>; // expected-note {{in instantiation}}
template class B<long>; // expected-note 4 {{in instantiation}}
}
// PR7281
namespace test16 {
class A { ~A(); }; // expected-note 2{{declared private here}}
void b() { throw A(); } // expected-error{{temporary of type 'test16::A' has private destructor}} \
// expected-error{{exception object of type 'test16::A' has private destructor}}
}
// rdar://problem/8146294
namespace test17 {
class A {
template <typename T> class Inner { }; // expected-note {{declared private here}}
};
A::Inner<int> s; // expected-error {{'Inner' is a private member of 'test17::A'}}
}
namespace test18 {
template <class T> class A {};
class B : A<int> {
A<int> member;
};
// FIXME: this access to A should be forbidden (because C++ is dumb),
// but LookupResult can't express the necessary information to do
// the check, so we aggressively suppress access control.
class C : B {
A<int> member;
};
}
// PR8325
namespace test19 {
class A { ~A(); };
// The destructor is not implicitly referenced here. Contrast to test16,
// testing PR7281, earlier in this file.
void b(A* x) { throw x; }
}
// PR7930
namespace test20 {
class Foo {
Foo(); // expected-note {{implicitly declared private here}}
};
Foo::Foo() {}
void test() {
Foo a; // expected-error {{calling a private constructor}}
}
}
namespace test21 {
template <class T> class A {
void foo();
void bar();
class Inner; // expected-note {{implicitly declared private here}}
public:
void baz();
};
template <class T> class A<T>::Inner {};
class B {
template <class T> class A<T>::Inner; // expected-error{{non-friend class member 'Inner' cannot have a qualified name}}
};
void test() {
A<int>::Inner i; // expected-error {{'Inner' is a private member}}
}
}
namespace rdar8876150 {
struct A { operator bool(); };
struct B : private A { using A::operator bool; };
bool f() {
B b;
return !b;
}
}
namespace test23 {
template <typename T> class A {
A();
static A instance;
};
template <typename T> A<T> A<T>::instance;
template class A<int>;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/p6.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// C++0x [class.access]p6:
// All access controls in [class.access] affect the ability to
// access a class member name from a particular scope. For purposes
// of access control, the base-specifiers of a class and the
// definitions of class members that appear outside of the class
// definition are considered to be within the scope of that
// class. In particular, access controls apply as usual to member
// names accessed as part of a function return type, even though it
// is not possible to determine the access privileges of that use
// without first parsing the rest of the function
// declarator. Similarly, access control for implicit calls to the
// constructors, the conversion functions, or the destructor called
// to create and destroy a static data member is performed as if
// these calls appeared in the scope of the member's class.
struct Public {}; struct Protected {}; struct Private {};
namespace test0 {
class A {
typedef int type; // expected-note {{declared private here}}
type foo();
};
A::type foo() { } // expected-error {{'type' is a private member}}
A::type A::foo() { }
}
// conversion decls
namespace test1 {
class A {
public:
A();
operator Public ();
A(Public);
protected:
operator Protected (); // expected-note {{declared protected here}}
A(Protected); // expected-note {{declared protected here}}
private:
operator Private (); // expected-note {{declared private here}}
A(Private); // expected-note {{declared private here}}
};
void test() {
A a;
Public pub = a;
Protected prot = a; // expected-error {{'operator Protected' is a protected member}}
Private priv = a; // expected-error {{'operator Private' is a private member}}
A apub = pub;
A aprot = prot; // expected-error {{protected constructor}}
A apriv = priv; // expected-error {{private constructor}}
}
}
// PR6967
namespace test2 {
class A {
public:
template <class T> static void set(T &t, typename T::type v) {
t.value = v;
}
template <class T> static typename T::type get(const T &t) {
return t.value;
}
};
class B {
friend class A;
private:
typedef int type;
type value;
};
int test() {
B b;
A::set(b, 0);
return A::get(b);
}
}
namespace test3 {
class Green {}; class Blue {};
// We have to wrap this in a class because a partial specialization
// isn't actually in the context of the template.
struct Outer {
template <class T, class Nat> class A {
};
};
template <class T> class Outer::A<T, typename T::nature> {
public:
static void foo(); // expected-note {{'Outer::A<B, Green>::foo' declared here}}
};
class B {
private: typedef Green nature;
friend class Outer;
};
void test() {
Outer::A<B, Green>::foo();
Outer::A<B, Blue>::foo(); // expected-error {{no member named 'foo' in 'test3::Outer::A<test3::B, test3::Blue>'; did you mean 'Outer::A<B, Green>::foo'?}}
}
}
namespace test4 {
template <class T> class A {
private: typedef int type;
template <class U> friend void foo(U &, typename U::type);
};
template <class U> void foo(U &, typename U::type) {}
void test() {
A<int> a;
foo(a, 0);
}
}
// PR7644
namespace test5 {
class A {
enum Enum { E0, E1, E2 }; // expected-note 4 {{declared private here}}
template <Enum> void foo();
template <Enum> class bar;
};
template <A::Enum en> void A::foo() {}
template <A::Enum en> class A::bar {};
template <A::Enum en> void foo() {} // expected-error {{'Enum' is a private member of 'test5::A'}}
template <A::Enum en> class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}}
class B {
template <A::Enum en> void foo() {} // expected-error {{'Enum' is a private member of 'test5::A'}}
template <A::Enum en> class bar {}; // expected-error {{'Enum' is a private member of 'test5::A'}}
};
}
namespace test6 {
class A {
public: class public_inner {};
protected: class protected_inner {};
private: class private_inner {}; // expected-note {{declared private here}}
};
class B : A {
public_inner a;
protected_inner b;
private_inner c; // expected-error {{'private_inner' is a private member of 'test6::A'}}
};
}
// PR9229
namespace test7 {
void foo(int arg[1]);
class A {
void check();
};
class B {
friend class A;
A ins;
};
void A::check() {
void foo(int arg[__builtin_offsetof(B, ins)]);
}
}
// rdar://problem/10155256
namespace test8 {
class A {
typedef void* (A::*UnspecifiedBoolType)() const;
operator UnspecifiedBoolType() const; // expected-note {{implicitly declared private here}}
};
void test(A &a) {
if (a) return; // expected-error-re {{'operator void *(test8::A::*)(){{( __attribute__\(\(thiscall\)\))?}} const' is a private member of 'test8::A'}}
}
}
namespace test9 {
class A {
operator char*() const; // expected-note {{implicitly declared private here}}
};
void test(A &a) {
delete a; // expected-error {{'operator char *' is a private member of 'test9::A'}}
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/class.access.base/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// C++0x [class.access.base]p1(a):
// If a class is declared to be a base class for another class using
// the public access specifier, the public members of the base class
// are accessible as public members of the derived class and protected
// members of the base class are accessible as protected members of
// the derived class.
namespace test0 {
class Base {
public: int pub; static int spub;
protected: int prot; static int sprot; // expected-note 4 {{declared protected here}}
private: int priv; static int spriv; // expected-note 8 {{declared private here}}
};
class Test : public Base {
void test() {
pub++;
spub++;
prot++;
sprot++;
priv++; // expected-error {{private member}}
spriv++; // expected-error {{private member}}
Base::pub++;
Base::spub++;
Base::prot++;
Base::sprot++;
Base::priv++; // expected-error {{private member}}
Base::spriv++; // expected-error {{private member}}
}
};
void test(Test *t) {
t->pub++;
t->spub++;
t->prot++; // expected-error {{protected member}}
t->sprot++; // expected-error {{protected member}}
t->priv++; // expected-error {{private member}}
t->spriv++; // expected-error {{private member}}
t->Base::pub++;
t->Base::spub++;
t->Base::prot++; // expected-error {{protected member}}
t->Base::sprot++; // expected-error {{protected member}}
t->Base::priv++; // expected-error {{private member}}
t->Base::spriv++; // expected-error {{private member}}
}
}
// C++0x [class.access.base]p1(b):
// If a class is declared to be a base class for another class using
// the protected access specifier, the public and protected members
// of the base class are accessible as protected members of the
// derived class.
namespace test1 {
class Base { // expected-note 6{{member is declared here}}
public:
int pub; // expected-note{{member is declared here}}
static int spub; // expected-note{{member is declared here}}
protected: int prot; static int sprot; // expected-note 4 {{declared protected here}}
private: int priv; static int spriv; // expected-note 8 {{declared private here}}
};
class Test : protected Base { // expected-note 6 {{declared protected here}} expected-note 8 {{constrained by protected inheritance here}}
void test() {
pub++;
spub++;
prot++;
sprot++;
priv++; // expected-error {{private member}}
spriv++; // expected-error {{private member}}
Base::pub++;
Base::spub++;
Base::prot++;
Base::sprot++;
Base::priv++; // expected-error {{private member}}
Base::spriv++; // expected-error {{private member}}
}
};
void test(Test *t) {
t->pub++; // expected-error {{protected member}} expected-error {{protected base class}}
t->spub++; // expected-error {{protected member}}
t->prot++; // expected-error {{protected member}} expected-error {{protected base class}}
t->sprot++; // expected-error {{protected member}}
t->priv++; // expected-error {{private member}} expected-error {{protected base class}}
t->spriv++; // expected-error {{private member}}
// Two possible errors here: one for Base, one for the member
t->Base::pub++; // expected-error {{protected member}} expected-error {{protected base class}}
t->Base::spub++; // expected-error {{protected member}}
t->Base::prot++; // expected-error 2 {{protected member}} expected-error {{protected base class}}
t->Base::sprot++; // expected-error 2 {{protected member}}
t->Base::priv++; // expected-error {{protected member}} expected-error {{private member}} expected-error {{protected base class}}
t->Base::spriv++; // expected-error {{protected member}} expected-error {{private member}}
}
}
// C++0x [class.access.base]p1(b):
// If a class is declared to be a base class for another class using
// the private access specifier, the public and protected members of
// the base class are accessible as private members of the derived
// class.
namespace test2 {
class Base { // expected-note 6{{member is declared here}}
public:
int pub; // expected-note{{member is declared here}}
static int spub; // expected-note{{member is declared here}}
protected:
int prot; // expected-note {{declared protected here}} \
// expected-note{{member is declared here}}
static int sprot; // expected-note {{declared protected here}} \
// expected-note{{member is declared here}}
private:
int priv; // expected-note 4 {{declared private here}}
static int spriv; // expected-note 4 {{declared private here}}
};
class Test : private Base { // expected-note 6 {{declared private here}} \
// expected-note 10 {{constrained by private inheritance here}}
void test() {
pub++;
spub++;
prot++;
sprot++;
priv++; // expected-error {{private member}}
spriv++; // expected-error {{private member}}
Base::pub++;
Base::spub++;
Base::prot++;
Base::sprot++;
Base::priv++; // expected-error {{private member}}
Base::spriv++; // expected-error {{private member}}
}
};
void test(Test *t) {
t->pub++; // expected-error {{private member}} expected-error {{private base class}}
t->spub++; // expected-error {{private member}}
t->prot++; // expected-error {{private member}} expected-error {{private base class}}
t->sprot++; // expected-error {{private member}}
t->priv++; // expected-error {{private member}} expected-error {{private base class}}
t->spriv++; // expected-error {{private member}}
t->Base::pub++; // expected-error {{private member}} expected-error {{private base class}}
t->Base::spub++; // expected-error {{private member}}
t->Base::prot++; // expected-error {{protected member}} expected-error {{private member}} expected-error {{private base class}}
t->Base::sprot++; // expected-error {{protected member}} expected-error {{private member}}
t->Base::priv++; // expected-error 2 {{private member}} expected-error {{private base class}}
t->Base::spriv++; // expected-error 2 {{private member}}
}
}
namespace PR12788 {
class A {
protected:
struct {
int x;
};
};
class B : A {
void f() {
++x;
A::x++;
}
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/class.access.base/p5.cpp
|
// RUN: %clang_cc1 -verify %s
namespace test0 {
struct A {
static int x;
};
struct B : A {};
struct C : B {};
int test() {
return A::x
+ B::x
+ C::x;
}
}
namespace test1 {
struct A {
private: static int x; // expected-note 5 {{declared private here}}
static int test() { return x; }
};
struct B : public A {
static int test() { return x; } // expected-error {{private member}}
};
struct C : private A {
static int test() { return x; } // expected-error {{private member}}
};
struct D {
public: static int x; // expected-note{{member is declared here}}
static int test() { return x; }
};
struct E : private D { // expected-note{{constrained by private inheritance}}
static int test() { return x; }
};
int test() {
return A::x // expected-error {{private member}}
+ B::x // expected-error {{private member}}
+ C::x // expected-error {{private member}}
+ D::x
+ E::x; // expected-error {{private member}}
}
}
namespace test2 {
class A {
protected: static int x; // expected-note{{member is declared here}}
};
class B : private A {}; // expected-note {{private inheritance}}
class C : private A {
int test(B *b) {
return b->x; // expected-error {{private member}}
}
};
}
namespace test3 {
class A {
protected: static int x;
};
class B : public A {};
class C : private A {
int test(B *b) {
// x is accessible at C when named in A.
// A is an accessible base of B at C.
// Therefore this succeeds.
return b->x;
}
};
}
// Don't crash. <rdar://12926092>
// Note that 'field' is indeed a private member of X but that access
// is indeed ultimately constrained by the protected inheritance from Y.
// If someone wants to put the effort into improving this diagnostic,
// they can feel free; even explaining it in person would be a pain.
namespace test4 {
class Z;
class X {
public:
void f(Z *p);
private:
int field; // expected-note {{member is declared here}}
};
class Y : public X { };
class Z : protected Y { }; // expected-note 2 {{constrained by protected inheritance here}}
void X::f(Z *p) {
p->field = 0; // expected-error {{cannot cast 'test4::Z' to its protected base class 'test4::X'}} expected-error {{'field' is a private member of 'test4::X'}}
}
}
// TODO: flesh out these cases
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/class.friend/p2-cxx03.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
template<typename T>
class X0 {
friend T; // expected-warning{{non-class friend type 'T' is a C++11 extension}}
};
class X1 { };
enum E1 { };
X0<X1> x0a;
X0<X1 *> x0b;
X0<int> x0c;
X0<E1> x0d;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/class.friend/p3-cxx0x.cpp
|
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
template<typename T>
class X0 {
friend T;
};
class Y1 { };
enum E1 { };
X0<Y1> x0a;
X0<Y1 *> x0b;
X0<int> x0c;
X0<E1> x0d;
template<typename T>
class X1 {
friend typename T::type; // expected-error{{no type named 'type' in 'Y1'}}
};
struct Y2 {
struct type { };
};
struct Y3 {
typedef int type;
};
X1<Y2> x1a;
X1<Y3> x1b;
X1<Y1> x1c; // expected-note{{in instantiation of template class 'X1<Y1>' requested here}}
template<typename T> class B;
template<typename T>
class A {
T x;
public:
class foo {};
static int y;
template <typename S> friend class B<S>::ty; // expected-warning {{dependent nested name specifier 'B<S>::' for friend class declaration is not supported}}
};
template<typename T> class B { typedef int ty; };
template<> class B<int> {
class ty {
static int f(A<int> &a) { return a.y; } // ok, befriended
};
};
int f(A<char> &a) { return a.y; } // FIXME: should be an error
struct {
// Ill-formed
int friend; // expected-error {{'friend' must appear first in a non-function declaration}}
unsigned friend int; // expected-error {{'friend' must appear first in a non-function declaration}}
const volatile friend int; // expected-error {{'friend' must appear first in a non-function declaration}}
int
friend; // expected-error {{'friend' must appear first in a non-function declaration}}
// OK
int friend foo(void);
friend int;
friend const volatile int;
friend
float;
template<typename T> friend class A<T>::foo; // expected-warning {{not supported}}
} a;
void testA() { (void)sizeof(A<int>); }
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/class.friend/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// C++'0x [class.friend] p1:
// A friend of a class is a function or class that is given permission to use
// the private and protected member names from the class. A class specifies
// its friends, if any, by way of friend declarations. Such declarations give
// special access rights to the friends, but they do not make the nominated
// friends members of the befriending class.
struct S { static void f(); }; // expected-note 2 {{'S' declared here}}
S* g() { return 0; } // expected-note 2 {{'g' declared here}}
struct X {
friend struct S;
friend S* g();
};
void test1() {
S s;
g()->f();
S::f();
X::g(); // expected-error{{no member named 'g' in 'X'; did you mean simply 'g'?}}
X::S x_s; // expected-error{{no type named 'S' in 'X'; did you mean simply 'S'?}}
X x;
x.g(); // expected-error{{no member named 'g' in 'X'}}
}
// Test that we recurse through namespaces to find already declared names, but
// new names are declared within the enclosing namespace.
namespace N {
struct X {
friend struct S;
friend S* g();
friend struct S2;
friend struct S2* g2();
};
struct S2 { static void f2(); }; // expected-note 2 {{'S2' declared here}}
S2* g2() { return 0; } // expected-note 2 {{'g2' declared here}}
void test() {
g()->f();
S s;
S::f();
X::g(); // expected-error{{no member named 'g' in 'N::X'; did you mean simply 'g'?}}
X::S x_s; // expected-error{{no type named 'S' in 'N::X'; did you mean simply 'S'?}}
X x;
x.g(); // expected-error{{no member named 'g' in 'N::X'}}
g2();
S2 s2;
::g2(); // expected-error{{no member named 'g2' in the global namespace; did you mean simply 'g2'?}}
::S2 g_s2; // expected-error{{no type named 'S2' in the global namespace; did you mean simply 'S2'?}}
X::g2(); // expected-error{{no member named 'g2' in 'N::X'; did you mean simply 'g2'?}}
X::S2 x_s2; // expected-error{{no type named 'S2' in 'N::X'; did you mean simply 'S2'?}}
x.g2(); // expected-error{{no member named 'g2' in 'N::X'}}
}
}
namespace test0 {
class ClassFriend {
void test();
};
class MemberFriend {
public:
void test();
};
void declared_test();
class Class {
static void member(); // expected-note 2 {{declared private here}}
friend class ClassFriend;
friend class UndeclaredClassFriend;
friend void undeclared_test();
friend void declared_test();
friend void MemberFriend::test();
};
void declared_test() {
Class::member();
}
void undeclared_test() {
Class::member();
}
void unfriended_test() {
Class::member(); // expected-error {{'member' is a private member of 'test0::Class'}}
}
void ClassFriend::test() {
Class::member();
}
void MemberFriend::test() {
Class::member();
}
class UndeclaredClassFriend {
void test() {
Class::member();
}
};
class ClassNonFriend {
void test() {
Class::member(); // expected-error {{'member' is a private member of 'test0::Class'}}
}
};
}
// Make sure that friends have access to inherited protected members.
namespace test2 {
struct X;
class ilist_half_node {
friend struct ilist_walker_bad;
X *Prev;
protected:
X *getPrev() { return Prev; } // expected-note{{member is declared here}}
};
class ilist_node : private ilist_half_node { // expected-note {{declared private here}} expected-note {{constrained by private inheritance here}}
friend struct ilist_walker;
X *Next;
X *getNext() { return Next; } // expected-note {{declared private here}}
};
struct X : ilist_node {};
struct ilist_walker {
static X *getPrev(X *N) { return N->getPrev(); }
static X *getNext(X *N) { return N->getNext(); }
};
struct ilist_walker_bad {
static X *getPrev(X *N) { return N->getPrev(); } // \
// expected-error {{'getPrev' is a private member of 'test2::ilist_half_node'}} \
// expected-error {{cannot cast 'test2::X' to its private base class 'test2::ilist_half_node'}}
static X *getNext(X *N) { return N->getNext(); } // \
// expected-error {{'getNext' is a private member of 'test2::ilist_node'}}
};
}
namespace test3 {
class A { protected: int x; }; // expected-note {{declared protected here}}
class B : public A {
friend int foo(B*);
};
int foo(B *p) {
return p->x;
}
int foo(const B *p) {
return p->x; // expected-error {{'x' is a protected member of 'test3::A'}}
}
}
namespace test3a {
class A { protected: int x; };
class B : public A {
friend int foo(B*);
};
int foo(B * const p) {
return p->x;
}
}
namespace test4 {
template <class T> class Holder {
T object;
friend bool operator==(Holder &a, Holder &b) {
return a.object == b.object; // expected-error {{invalid operands to binary expression}}
}
};
struct Inequal {};
bool test() {
Holder<Inequal> a, b;
return a == b; // expected-note {{requested here}}
}
}
// PR6174
namespace test5 {
namespace ns {
class A;
}
class ns::A {
private: int x;
friend class B;
};
namespace ns {
class B {
int test(A *p) { return p->x; }
};
}
}
// PR6207
namespace test6 {
struct A {};
struct B {
friend A::A();
friend A::~A();
friend A &A::operator=(const A&);
};
}
namespace test7 {
template <class T> struct X {
X();
~X();
void foo();
void bar();
};
class A {
friend void X<int>::foo();
friend X<int>::X();
friend X<int>::X(const X&);
private:
A(); // expected-note 2 {{declared private here}}
};
template<> void X<int>::foo() {
A a;
}
template<> void X<int>::bar() {
A a; // expected-error {{calling a private constructor}}
}
template<> X<int>::X() {
A a;
}
template<> X<int>::~X() {
A a; // expected-error {{calling a private constructor}}
}
}
// Return types, parameters and default arguments to friend functions.
namespace test8 {
class A {
typedef int I; // expected-note 4 {{declared private here}}
static const I x = 0; // expected-note {{implicitly declared private here}}
friend I f(I i);
template<typename T> friend I g(I i);
};
const A::I A::x;
A::I f(A::I i = A::x) {}
template<typename T> A::I g(A::I i) {
T t;
}
template A::I g<A::I>(A::I i);
A::I f2(A::I i = A::x) {} // expected-error 3 {{is a private member of}}
template<typename T> A::I g2(A::I i) { // expected-error 2 {{is a private member of}}
T t;
}
template A::I g2<A::I>(A::I i);
}
// PR6885
namespace test9 {
class B {
friend class test9;
};
}
// PR7230
namespace test10 {
extern "C" void test10_f(void);
extern "C" void test10_g(void);
namespace NS {
class C {
void foo(void); // expected-note {{declared private here}}
friend void test10::test10_f(void);
};
static C* bar;
}
void test10_f(void) {
NS::bar->foo();
}
void test10_g(void) {
NS::bar->foo(); // expected-error {{private member}}
}
}
// PR8705
namespace test11 {
class A {
public:
void test0(int);
void test1(int);
void test2(int);
void test3(int);
};
class B {
typedef int private_type; // expected-note 2 {{implicitly declared private here}}
friend void A::test0(int);
friend void A::test1(int);
};
void A::test0(B::private_type x) {}
void A::test1(int x = B::private_type()) {}
void A::test2(B::private_type x) {} // expected-error {{'private_type' is a private member of 'test11::B'}}
void A::test3(int x = B::private_type()) {} // expected-error {{'private_type' is a private member of 'test11::B'}}
}
// PR9221
namespace test12 {
struct A {
void foo();
};
class B : private A {
friend void A::foo();
void *mem;
};
void A::foo() {
void *var = static_cast<B*>(this)->mem;
}
}
namespace PR9103 {
struct base {
protected:
static void foo(void) {}
};
struct cls: base {
friend void bar(void) {
base::foo();
}
};
}
// PR13642. When computing the effective context, we were walking up
// the DC chain for the canonical decl, which is unfortunate if that's
// (e.g.) a friend declaration.
namespace test14 {
class A {
class B { // expected-note {{implicitly declared private here}}
static int i;
friend void c();
};
};
void c() {
A::B::i = 5; // expected-error {{'B' is a private member of 'test14::A'}}
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/class.friend/p11.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// rdar://problem/8540720
namespace test0 {
void foo() {
void bar();
class A {
friend void bar();
};
}
}
namespace test1 {
void foo() {
class A {
friend void bar(); // expected-error {{no matching function found in local scope}}
};
}
}
namespace test2 {
void bar(); // expected-note {{'::test2::bar' declared here}}
void foo() { // expected-note {{'::test2::foo' declared here}}
struct S1 {
friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}}
// expected-note@-1{{'::test2::foo' declared here}}
// TODO: the above note should go on line 24
};
void foo(); // expected-note {{local declaration nearly matches}}
struct S2 {
friend void foo();
};
{
struct S2 {
friend void foo(); // expected-error {{no matching function found in local scope}}
};
}
{
int foo;
struct S3 {
friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}}
};
}
struct S4 {
friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
// expected-note@-1 2 {{'::test2::bar' declared here}}
// TODO: the above two notes should go on line 22
};
{ void bar(); }
struct S5 {
friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
};
{
void bar();
struct S6 {
friend void bar();
};
}
struct S7 {
void bar() { Inner::f(); }
struct Inner {
friend void bar();
static void f() {}
};
};
void bar(); // expected-note {{'bar' declared here}}
struct S8 {
struct Inner {
friend void bar();
};
};
struct S9 {
struct Inner {
friend void baz(); // expected-error {{no matching function 'baz' found in local scope; did you mean 'bar'?}}
};
};
struct S10 {
void quux() {}
void foo() {
struct Inner1 {
friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
friend void quux(); // expected-error {{no matching function found in local scope}}
};
void bar();
struct Inner2 {
friend void bar();
};
}
};
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/class.friend/p9-cxx0x.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// C++98 [class.friend]p7:
// C++11 [class.friend]p9:
// A name nominated by a friend declaration shall be accessible in
// the scope of the class containing the friend declaration.
// PR12328
// Simple, non-templated case.
namespace test0 {
class X {
void f(); // expected-note {{implicitly declared private here}}
};
class Y {
friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test0::X'}}
};
}
// Templated but non-dependent.
namespace test1 {
class X {
void f(); // expected-note {{implicitly declared private here}}
};
template <class T> class Y {
friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test1::X'}}
};
}
// Dependent but instantiated at the right type.
namespace test2 {
template <class T> class Y;
class X {
void f();
friend class Y<int>;
};
template <class T> class Y {
friend void X::f();
};
template class Y<int>;
}
// Dependent and instantiated at the wrong type.
namespace test3 {
template <class T> class Y;
class X {
void f(); // expected-note {{implicitly declared private here}}
friend class Y<int>;
};
template <class T> class Y {
friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test3::X'}}
};
template class Y<float>; // expected-note {{in instantiation}}
}
// Dependent because dependently-scoped.
namespace test4 {
template <class T> class X {
void f();
};
template <class T> class Y {
friend void X<T>::f();
};
}
// Dependently-scoped, no friends.
namespace test5 {
template <class T> class X {
void f(); // expected-note {{implicitly declared private here}}
};
template <class T> class Y {
friend void X<T>::f(); // expected-error {{friend function 'f' is a private member of 'test5::X<int>'}}
};
template class Y<int>; // expected-note {{in instantiation}}
}
// Dependently-scoped, wrong friend.
namespace test6 {
template <class T> class Y;
template <class T> class X {
void f(); // expected-note {{implicitly declared private here}}
friend class Y<float>;
};
template <class T> class Y {
friend void X<T>::f(); // expected-error {{friend function 'f' is a private member of 'test6::X<int>'}}
};
template class Y<int>; // expected-note {{in instantiation}}
}
// Dependently-scoped, right friend.
namespace test7 {
template <class T> class Y;
template <class T> class X {
void f();
friend class Y<int>;
};
template <class T> class Y {
friend void X<T>::f();
};
template class Y<int>;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/class.friend/p6.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
void f1();
struct X {
void f2();
};
struct Y {
friend void ::f1() { } // expected-error{{friend function definition cannot be qualified with '::'}}
friend void X::f2() { } // expected-error{{friend function definition cannot be qualified with 'X::'}}
};
template <typename T> struct Z {
friend void T::f() {} // expected-error{{friend function definition cannot be qualified with 'T::'}}
};
void local() {
void f();
struct Local {
friend void f() { } // expected-error{{friend function cannot be defined in a local class}}
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/class.access.nest/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// Derived from GNU's std::string
namespace test0 {
class A {
struct B {
unsigned long length;
};
struct C : B {
static const unsigned long max_length;
};
};
const unsigned long A::C::max_length = sizeof(B);
}
// Example from the standard.
namespace test1 {
class E {
int x;
class B {};
class I {
B b;
int y; // expected-note {{declared private here}}
void f(E* p, int i) {
p->x = i;
}
};
int g(I* p) { return p->y; } // expected-error {{'y' is a private member of 'test1::E::I'}}
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/class.access.dcl/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// This is just the test for [namespace.udecl]p4 with 'using'
// uniformly stripped out.
// C++03 [namespace.udecl]p4:
// A using-declaration used as a member-declaration shall refer to a
// member of a base class of the class being defined, shall refer to
// a member of an anonymous union that is a member of a base class
// of the class being defined, or shall refer to an enumerator for
// an enumeration type that is a member of a base class of the class
// being defined.
// There is no directly analogous paragraph in C++0x, and the feature
// works sufficiently differently there that it needs a separate test.
namespace test0 {
namespace NonClass {
typedef int type;
struct hiding {};
int hiding;
static union { double union_member; };
enum tagname { enumerator };
}
class Test0 {
NonClass::type; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
NonClass::hiding; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
NonClass::union_member; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
NonClass::enumerator; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
};
}
struct Opaque0 {};
namespace test1 {
struct A {
typedef int type;
struct hiding {}; // expected-note {{previous use is here}}
Opaque0 hiding;
union { double union_member; };
enum tagname { enumerator };
};
struct B : A {
A::type; // expected-warning {{access declarations are deprecated}}
A::hiding; // expected-warning {{access declarations are deprecated}}
A::union_member; // expected-warning {{access declarations are deprecated}}
A::enumerator; // expected-warning {{access declarations are deprecated}}
A::tagname; // expected-warning {{access declarations are deprecated}}
void test0() {
type t = 0;
}
void test1() {
typedef struct A::hiding local;
struct hiding _ = local();
}
void test2() {
union hiding _; // expected-error {{tag type that does not match previous}}
}
void test3() {
char array[sizeof(union_member) == sizeof(double) ? 1 : -1];
}
void test4() {
enum tagname _ = enumerator;
}
void test5() {
Opaque0 _ = hiding;
}
};
}
namespace test2 {
struct A {
typedef int type;
struct hiding {}; // expected-note {{previous use is here}}
int hiding;
union { double union_member; };
enum tagname { enumerator };
};
template <class T> struct B : A {
A::type; // expected-warning {{access declarations are deprecated}}
A::hiding; // expected-warning {{access declarations are deprecated}}
A::union_member; // expected-warning {{access declarations are deprecated}}
A::enumerator; // expected-warning {{access declarations are deprecated}}
A::tagname; // expected-warning {{access declarations are deprecated}}
void test0() {
type t = 0;
}
void test1() {
typedef struct A::hiding local;
struct hiding _ = local();
}
void test2() {
union hiding _; // expected-error {{tag type that does not match previous}}
}
void test3() {
char array[sizeof(union_member) == sizeof(double) ? 1 : -1];
}
void test4() {
enum tagname _ = enumerator;
}
void test5() {
Opaque0 _ = hiding;
}
};
}
namespace test3 {
struct hiding {};
template <class T> struct A {
typedef int type; // expected-note {{target of using declaration}}
struct hiding {};
Opaque0 hiding;
union { double union_member; };
enum tagname { enumerator }; // expected-note {{target of using declaration}}
};
template <class T> struct B : A<T> {
A<T>::type; // expected-error {{dependent using declaration resolved to type without 'typename'}} // expected-warning {{access declarations are deprecated}}
A<T>::hiding; // expected-warning {{access declarations are deprecated}}
A<T>::union_member; // expected-warning {{access declarations are deprecated}}
A<T>::enumerator; // expected-warning {{access declarations are deprecated}}
A<T>::tagname; // expected-error {{dependent using declaration resolved to type without 'typename'}} // expected-warning {{access declarations are deprecated}}
// FIXME: re-enable these when the various bugs involving tags are fixed
#if 0
void test1() {
typedef struct A<T>::hiding local;
struct hiding _ = local();
}
void test2() {
typedef struct A<T>::hiding local;
union hiding _ = local();
}
#endif
void test3() {
char array[sizeof(union_member) == sizeof(double) ? 1 : -1];
}
#if 0
void test4() {
enum tagname _ = enumerator;
}
#endif
void test5() {
Opaque0 _ = hiding;
}
};
template struct B<int>; // expected-note {{in instantiation}}
}
namespace test4 {
struct Base {
int foo();
};
struct Unrelated {
int foo();
};
struct Subclass : Base {
};
namespace InnerNS {
int foo();
}
// We should be able to diagnose these without instantiation.
template <class T> struct C : Base {
InnerNS::foo; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
Base::bar; // expected-error {{no member named 'bar'}} expected-warning {{access declarations are deprecated}}
Unrelated::foo; // expected-error {{not a base class}} expected-warning {{access declarations are deprecated}}
C::foo; // legal in C++03 // expected-warning {{access declarations are deprecated}}
Subclass::foo; // legal in C++03 // expected-warning {{access declarations are deprecated}}
int bar(); //expected-note {{target of using declaration}}
C::bar; // expected-error {{refers to its own class}} expected-warning {{access declarations are deprecated}}
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/class.protected/p1-cxx11.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
// PR12497
namespace test0 {
class A {
protected:
A() {}
A(const A &) {}
~A() {}
A &operator=(const A &a) { return *this; }
};
class B : public A {};
void test() {
B b1;
B b2 = b1;
b1 = b2;
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class.access/class.protected/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
namespace test0 {
class A {
protected: int x; // expected-note 3 {{declared}} \
// expected-note {{member is declared here}}
static int sx; // expected-note 3 {{declared}} \
// expected-note {{member is declared here}}
};
class B : public A {
};
class C : protected A { // expected-note {{declared}}
};
class D : private B { // expected-note 3 {{constrained}}
};
void test(A &a) {
(void) a.x; // expected-error {{'x' is a protected member}}
(void) a.sx; // expected-error {{'sx' is a protected member}}
}
void test(B &b) {
(void) b.x; // expected-error {{'x' is a protected member}}
(void) b.sx; // expected-error {{'sx' is a protected member}}
}
void test(C &c) {
(void) c.x; // expected-error {{'x' is a protected member}} expected-error {{protected base class}}
(void) c.sx; // expected-error {{'sx' is a protected member}}
}
void test(D &d) {
(void) d.x; // expected-error {{'x' is a private member}} expected-error {{private base class}}
(void) d.sx; // expected-error {{'sx' is a private member}}
}
}
namespace test1 {
class A {
protected: int x;
static int sx;
static void test(A&);
};
class B : public A {
static void test(B&);
};
class C : protected A {
static void test(C&);
};
class D : private B {
static void test(D&);
};
void A::test(A &a) {
(void) a.x;
(void) a.sx;
}
void B::test(B &b) {
(void) b.x;
(void) b.sx;
}
void C::test(C &c) {
(void) c.x;
(void) c.sx;
}
void D::test(D &d) {
(void) d.x;
(void) d.sx;
}
}
namespace test2 {
class A {
protected: int x; // expected-note 3 {{can only access this member on an object of type}}
static int sx;
static void test(A&);
};
class B : public A {
static void test(A&);
};
class C : protected A {
static void test(A&);
};
class D : private B {
static void test(A&);
};
void A::test(A &a) {
(void) a.x;
(void) a.sx;
}
void B::test(A &a) {
(void) a.x; // expected-error {{'x' is a protected member}}
(void) a.sx;
}
void C::test(A &a) {
(void) a.x; // expected-error {{'x' is a protected member}}
(void) a.sx;
}
void D::test(A &a) {
(void) a.x; // expected-error {{'x' is a protected member}}
(void) a.sx;
}
}
namespace test3 {
class B;
class A {
protected: int x; //expected-note {{declared protected}} // expected-note {{can only access this member on an object of type}}
static int sx;
static void test(B&);
};
class B : public A {
static void test(B&);
};
class C : protected A {
static void test(B&);
};
class D : private B {
static void test(B&);
};
void A::test(B &b) {
(void) b.x;
(void) b.sx;
}
void B::test(B &b) {
(void) b.x;
(void) b.sx;
}
void C::test(B &b) {
(void) b.x; // expected-error {{'x' is a protected member}}
(void) b.sx;
}
void D::test(B &b) {
(void) b.x; // expected-error {{'x' is a protected member}}
(void) b.sx;
}
}
namespace test4 {
class C;
class A {
protected: int x; // expected-note 2{{declared protected here}} expected-note{{member is declared here}}
static int sx; // expected-note 3{{member is declared here}}
static void test(C&);
};
class B : public A {
static void test(C&);
};
class C : protected A { // expected-note 4 {{constrained}} expected-note 3 {{declared}}
static void test(C&);
};
class D : private B {
static void test(C&);
};
void A::test(C &c) {
(void) c.x; // expected-error {{'x' is a protected member}} \
// expected-error {{protected base class}}
(void) c.sx; // expected-error {{'sx' is a protected member}}
}
void B::test(C &c) {
(void) c.x; // expected-error {{'x' is a protected member}} \
// expected-error {{protected base class}}
(void) c.sx; // expected-error {{'sx' is a protected member}}
}
void C::test(C &c) {
(void) c.x;
(void) c.sx;
}
void D::test(C &c) {
(void) c.x; // expected-error {{'x' is a protected member}} \
// expected-error {{protected base class}}
(void) c.sx; // expected-error {{'sx' is a protected member}}
}
}
namespace test5 {
class D;
class A {
protected: int x; // expected-note 3{{member is declared here}}
static int sx; // expected-note 3{{member is declared here}}
static void test(D&);
};
class B : public A {
static void test(D&);
};
class C : protected A {
static void test(D&);
};
class D : private B { // expected-note 9 {{constrained}}
static void test(D&);
};
void A::test(D &d) {
(void) d.x; // expected-error {{'x' is a private member}} \
// expected-error {{cannot cast}}
(void) d.sx; // expected-error {{'sx' is a private member}}
}
void B::test(D &d) {
(void) d.x; // expected-error {{'x' is a private member}} \
// expected-error {{cannot cast}}
(void) d.sx; // expected-error {{'sx' is a private member}}
}
void C::test(D &d) {
(void) d.x; // expected-error {{'x' is a private member}} \
// expected-error {{cannot cast}}
(void) d.sx; // expected-error {{'sx' is a private member}}
}
void D::test(D &d) {
(void) d.x;
(void) d.sx;
}
}
namespace test6 {
class Static {};
class A {
protected:
void foo(int); // expected-note 3 {{can only access this member on an object of type}}
void foo(long);
static void foo(Static);
static void test(A&);
};
class B : public A {
static void test(A&);
};
class C : protected A {
static void test(A&);
};
class D : private B {
static void test(A&);
};
void A::test(A &a) {
a.foo(10);
a.foo(Static());
}
void B::test(A &a) {
a.foo(10); // expected-error {{'foo' is a protected member}}
a.foo(Static());
}
void C::test(A &a) {
a.foo(10); // expected-error {{'foo' is a protected member}}
a.foo(Static());
}
void D::test(A &a) {
a.foo(10); // expected-error {{'foo' is a protected member}}
a.foo(Static());
}
}
namespace test7 {
class Static {};
class A {
protected:
void foo(int); // expected-note 3 {{must name member using the type of the current context}}
void foo(long);
static void foo(Static);
static void test();
};
class B : public A {
static void test();
};
class C : protected A {
static void test();
};
class D : private B {
static void test();
};
void A::test() {
void (A::*x)(int) = &A::foo;
void (*sx)(Static) = &A::foo;
}
void B::test() {
void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}}
void (*sx)(Static) = &A::foo;
}
void C::test() {
void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}}
void (*sx)(Static) = &A::foo;
}
void D::test() {
void (A::*x)(int) = &A::foo; // expected-error {{'foo' is a protected member}}
void (*sx)(Static) = &A::foo;
}
}
namespace test8 {
class Static {};
class A {
protected:
void foo(int); // expected-note 3 {{must name member using the type of the current context}}
void foo(long);
static void foo(Static);
static void test();
};
class B : public A {
static void test();
};
class C : protected A {
static void test();
};
class D : private B {
static void test();
};
void call(void (A::*)(int));
void calls(void (*)(Static));
void A::test() {
call(&A::foo);
calls(&A::foo);
}
void B::test() {
call(&A::foo); // expected-error {{'foo' is a protected member}}
calls(&A::foo);
}
void C::test() {
call(&A::foo); // expected-error {{'foo' is a protected member}}
calls(&A::foo);
}
void D::test() {
call(&A::foo); // expected-error {{'foo' is a protected member}}
calls(&A::foo);
}
}
namespace test9 {
class A { // expected-note {{member is declared here}}
protected: int foo(); // expected-note 4 {{declared}} expected-note 3 {{can only access this member on an object of type}} expected-note 2 {{member is declared here}}
};
class B : public A { // expected-note {{member is declared here}}
friend class D;
};
class C : protected B { // expected-note {{declared}} \
// expected-note 9 {{constrained}}
};
class D : public A {
static void test(A &a) {
a.foo(); // expected-error {{'foo' is a protected member}}
a.A::foo(); // expected-error {{'foo' is a protected member}}
a.B::foo(); // expected-error {{'foo' is a protected member}}
a.C::foo(); // expected-error {{'foo' is a protected member}}
a.D::foo(); // expected-error {{'foo' is a protected member}}
}
static void test(B &b) {
b.foo();
b.A::foo();
b.B::foo(); // accessible as named in A
b.C::foo(); // expected-error {{'foo' is a protected member}}
}
static void test(C &c) {
c.foo(); // expected-error {{'foo' is a protected member}} \
// expected-error {{cannot cast}}
c.A::foo(); // expected-error {{'A' is a protected member}} \
// expected-error {{cannot cast}}
c.B::foo(); // expected-error {{'B' is a protected member}} \
// expected-error {{cannot cast}}
c.C::foo(); // expected-error {{'foo' is a protected member}} \
// expected-error {{cannot cast}}
}
static void test(D &d) {
d.foo();
d.A::foo();
d.B::foo();
d.C::foo(); // expected-error {{'foo' is a protected member}}
}
};
}
namespace test10 {
template<typename T> class A {
protected:
int foo();
int foo() const;
~A() { foo(); }
};
template class A<int>;
}
// rdar://problem/8360285: class.protected friendship
namespace test11 {
class A {
protected:
int foo();
};
class B : public A {
friend class C;
};
class C {
void test() {
B b;
b.A::foo();
}
};
}
// This friendship is considered because a public member of A would be
// a private member of C.
namespace test12 {
class A { protected: int foo(); };
class B : public virtual A {};
class C : private B { friend void test(); };
class D : private C, public virtual A {};
void test() {
D d;
d.A::foo();
}
}
// This friendship is not considered because a public member of A is
// inaccessible in C.
namespace test13 {
class A { protected: int foo(); }; // expected-note {{declared protected here}}
class B : private virtual A {};
class C : private B { friend void test(); };
class D : public virtual A {};
void test() {
D d;
d.A::foo(); // expected-error {{protected member}}
}
}
// PR8058
namespace test14 {
class A {
protected:
template <class T> void temp(T t); // expected-note {{must name member using the type of the current context}}
void nontemp(int); // expected-note {{must name member using the type of the current context}}
template <class T> void ovl_temp(T t); // expected-note {{must name member using the type of the current context}}
void ovl_temp(float);
void ovl_nontemp(int); // expected-note {{must name member using the type of the current context}}
void ovl_nontemp(float);
template <class T> void ovl_withtemp(T);
void ovl_withtemp(int); // expected-note {{must name member using the type of the current context}}
};
class B : public A {
void use() {
void (A::*ptr)(int);
ptr = &A::temp; // expected-error {{protected member}}
ptr = &A::nontemp; // expected-error {{protected member}}
ptr = &A::ovl_temp; // expected-error {{protected member}}
ptr = &A::ovl_nontemp; // expected-error {{protected member}}
ptr = &A::ovl_withtemp; // expected-error {{protected member}}
}
};
}
namespace test15 {
class A {
protected:
A(); // expected-note 2 {{protected constructor can only be used to construct a base class subobject}}
A(const A &); // expected-note {{protected constructor can only be used to construct a base class subobject}}
~A(); // expected-note 3 {{protected destructor can only be used to destroy a base class subobject}}
};
class B : public A {
// The uses here are fine.
B() {}
B(int i) : A() {}
~B() {}
// All these uses are bad.
void test0() {
A a; // expected-error {{protected constructor}} expected-error {{protected destructor}}
}
A *test1() {
return new A(); // expected-error {{protected constructor}}
}
void test2(A *a) {
delete a; // expected-error {{protected destructor}}
}
A test3(A *a) {
return *a; // expected-error {{protected constructor}}
}
void test4(A *a) {
a->~A(); // expected-error {{protected member}}
}
};
}
namespace test16 {
class A {
protected:
~A();
};
class B : public virtual A {
public:
~B() {}
};
class C : public B {
~C() {}
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/conv
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/conv/conv.prom/p4.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
// expected-no-diagnostics
enum X : short { A, B };
extern decltype(+A) x;
extern int x;
enum Y : long { C, D };
extern decltype(+C) y;
extern long y;
// An enum with a fixed underlying type has an integral promotion to that type,
// and to its promoted type.
enum B : bool { false_, true_ };
template<bool> struct T {};
T<false_> f;
T<true_> t;
// FIXME: DR1407 will make this ill-formed
T<+true_> q; // desired-error {{conversion from 'int' to 'bool'}}
enum B2 : bool {
a = false,
b = true,
c = false_,
d = true_,
// FIXME: DR1407 will make this ill-formed
e = +false_ // desired-error {{conversion from 'int' to 'bool'}}
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/conv
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/conv/conv.prom/p2.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -triple x86_64-pc-linux-gnu -ffreestanding %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -triple x86_64-pc-linux-gnu -ffreestanding -fshort-wchar %s
// expected-no-diagnostics
#include <stdint.h>
// In theory, the promoted types vary by platform; however, in reality they
// are quite consistent across all platforms where clang runs.
extern int promoted_wchar;
extern decltype(+L'a') promoted_wchar;
extern int promoted_char16;
extern decltype(+u'a') promoted_char16;
extern unsigned promoted_char32;
extern decltype(+U'a') promoted_char32;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/conv
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/conv/conv.qual/pr6089.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
bool is_char_ptr( const char* );
template< class T >
long is_char_ptr( T /* r */ );
// Note: the const here does not lead to a qualification conversion
template< class T >
void make_range( T* const r, bool );
template< class T >
void make_range( T& r, long );
void first_finder( const char*& Search )
{
make_range( Search, is_char_ptr(Search) );
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/conv
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/conv/conv.mem/p4.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct Base {
int data;
int method();
};
int (Base::*data_ptr) = &Base::data;
int (Base::*method_ptr)() = &Base::method;
namespace test0 {
struct Derived : Base {};
void test() {
int (Derived::*d) = data_ptr;
int (Derived::*m)() = method_ptr;
}
}
// Can't be inaccessible.
namespace test1 {
struct Derived : private Base {}; // expected-note 2 {{declared private here}}
void test() {
int (Derived::*d) = data_ptr; // expected-error {{cannot cast private base class 'Base' to 'test1::Derived'}}
int (Derived::*m)() = method_ptr; // expected-error {{cannot cast private base class 'Base' to 'test1::Derived'}}
}
};
// Can't be ambiguous.
namespace test2 {
struct A : Base {};
struct B : Base {};
struct Derived : A, B {};
void test() {
int (Derived::*d) = data_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test2::Derived':}}
int (Derived::*m)() = method_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test2::Derived':}}
}
}
// Can't be virtual.
namespace test3 {
struct Derived : virtual Base {};
void test() {
int (Derived::*d) = data_ptr; // expected-error {{conversion from pointer to member of class 'Base' to pointer to member of class 'test3::Derived' via virtual base 'Base' is not allowed}}
int (Derived::*m)() = method_ptr; // expected-error {{conversion from pointer to member of class 'Base' to pointer to member of class 'test3::Derived' via virtual base 'Base' is not allowed}}
}
}
// Can't be virtual even if there's a non-virtual path.
namespace test4 {
struct A : Base {};
struct Derived : Base, virtual A {}; // expected-warning {{direct base 'Base' is inaccessible due to ambiguity:\n struct test4::Derived -> struct Base\n struct test4::Derived -> struct test4::A -> struct Base}}
void test() {
int (Derived::*d) = data_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test4::Derived':}}
int (Derived::*m)() = method_ptr; // expected-error {{ambiguous conversion from pointer to member of base class 'Base' to pointer to member of derived class 'test4::Derived':}}
}
}
// PR6254: don't get thrown off by a virtual base.
namespace test5 {
struct A {};
struct Derived : Base, virtual A {};
void test() {
int (Derived::*d) = data_ptr;
int (Derived::*m)() = method_ptr;
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/conv
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/conv/conv.ptr/p2.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
namespace pr7801 {
extern void* x[];
void* dummy[] = { &x };
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.built/p25.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// expected-no-diagnostics
enum class Color { Red, Green, Blue };
struct ConvertsToColorA {
operator Color();
};
struct ConvertsToColorB {
operator Color();
};
Color foo(bool cond, ConvertsToColorA ca, ConvertsToColorB cb) {
return cond? ca : cb;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.built/p23.cpp
|
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
// expected-no-diagnostics
struct Variant {
template <typename T> operator T();
};
Variant getValue();
void testVariant() {
bool ret1 = getValue() || getValue();
bool ret2 = getValue() && getValue();
bool ret3 = !getValue();
}
struct ExplicitVariant {
template <typename T> explicit operator T();
};
ExplicitVariant getExplicitValue();
void testExplicitVariant() {
bool ret1 = getExplicitValue() || getExplicitValue();
bool ret2 = getExplicitValue() && getExplicitValue();
bool ret3 = !getExplicitValue();
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match/over.match.funcs/p4-0x.cpp
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
// expected-no-diagnostics
template<typename T> T &lvalue();
template<typename T> T &&xvalue();
template<typename T> T prvalue();
struct X0 {
int &f() &;
float &f() &&;
template<typename T> int &ft(T) &;
template<typename T> float &ft(T) &&;
typedef int &(*func_int_ref)();
typedef float &(*func_float_ref)();
operator func_int_ref() &;
operator func_float_ref() &&;
void g();
int &operator+(const X0&) &;
float &operator+(const X0&) &&;
template<typename T> int &operator+(const T&) &;
template<typename T> float &operator+(const T&) &&;
int &h() const&;
float &h() &&;
int &h2() const&;
float &h2() const&&;
};
void X0::g() {
int &ir1 = f();
int &ir2 = X0::f();
}
void test_ref_qualifier_binding() {
int &ir1 = lvalue<X0>().f();
float &fr1 = xvalue<X0>().f();
float &fr2 = prvalue<X0>().f();
int &ir2 = lvalue<X0>().ft(1);
float &fr3 = xvalue<X0>().ft(2);
float &fr4 = prvalue<X0>().ft(3);
}
void test_ref_qualifier_binding_with_surrogates() {
int &ir1 = lvalue<X0>()();
float &fr1 = xvalue<X0>()();
float &fr2 = prvalue<X0>()();
}
void test_ref_qualifier_binding_operators() {
int &ir1 = lvalue<X0>() + prvalue<X0>();
float &fr1 = xvalue<X0>() + prvalue<X0>();
float &fr2 = prvalue<X0>() + prvalue<X0>();
int &ir2 = lvalue<X0>() + 1;
float &fr3 = xvalue<X0>() + 2;
float &fr4 = prvalue<X0>() + 3;
}
void test_ref_qualifier_overloading() {
int &ir1 = lvalue<X0>().h();
float &fr1 = xvalue<X0>().h();
float &fr2 = prvalue<X0>().h();
int &ir2 = lvalue<X0>().h2();
float &fr3 = xvalue<X0>().h2();
float &fr4 = prvalue<X0>().h2();
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match/over.match.funcs
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match/over.match.funcs/over.match.oper/p3.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
namespace bullet2 {
// For non-member candidates, if no operand has a class type, only those
// non-member functions that have a matching enumeration parameter are
// candidates.
struct B { template<typename T> B(T); };
int operator~(B);
template<typename T> int operator%(B, T);
enum class E { e };
template<typename T> int f(T t) { return ~t; } // expected-error {{invalid argument type}}
template<typename T, typename U> int f(T t, U u) { return t % u; } // expected-error {{invalid operands to}}
int b1 = ~E::e; // expected-error {{invalid argument type}}
int b2 = f(E::e); // expected-note {{in instantiation of}}
int b3 = f(0, E::e);
int b4 = f(E::e, 0); // expected-note {{in instantiation of}}
}
namespace bullet3 {
// This is specifically testing the bullet:
// "do not have the same parameter-type-list as any non-template
// non-member candidate."
// The rest is sort of hard to test separately.
enum E1 { one };
enum E2 { two };
struct A;
A operator >= (E1, E1);
A operator >= (E1, const E2);
E1 a;
E2 b;
extern A test1;
extern decltype(a >= a) test1;
extern decltype(a >= b) test1;
template <typename T> A operator <= (E1, T);
extern bool test2;
extern decltype(a <= a) test2;
extern A test3;
extern decltype(a <= b) test3;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match/over.match.funcs
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s -verify
namespace ExplicitConv {
struct X { }; // expected-note 2{{candidate constructor}}
struct Y {
explicit operator X() const;
};
void test(const Y& y) {
X x(static_cast<X>(y));
X x2((X)y);
X x3 = y; // expected-error{{no viable conversion from 'const ExplicitConv::Y' to 'ExplicitConv::X'}}
}
}
namespace DR899 {
struct C { }; // expected-note 2 {{candidate constructor}}
struct A {
explicit operator int() const;
explicit operator C() const;
};
struct B {
int i;
B(const A& a): i(a) { }
};
int main() {
A a;
int i = a; // expected-error{{no viable conversion}}
int j(a);
C c = a; // expected-error{{no viable conversion}}
C c2(a);
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match/over.match.best/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
template<typename T> int &f0(T*, int);
float &f0(void*, int);
void test_f0(int* ip, void *vp) {
// One argument is better...
int &ir = f0(ip, 0);
// Prefer non-templates to templates
float &fr = f0(vp, 0);
}
// Partial ordering of function template specializations will be tested
// elsewhere
// FIXME: Initialization by user-defined conversion is tested elsewhere
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match/over.match.best/over.best.ics
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.list/p6.cpp
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
// rdar://problem/11120365
namespace test0 {
template <class T> struct A {
static void foo(const T &t) {}
static void foo(T &&t) {
t.foo(); // expected-error {{member reference base type 'int' is not a structure or union}}
}
};
void test() {
A<int>::foo({}); // expected-note {{requested here}}
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match/over.match.best/over.best.ics
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match/over.match.best/over.best.ics/over.ics.user/p3-0x.cpp
|
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
namespace PR6285 {
template<typename T> struct identity
{ typedef T type; };
struct D {
template<typename T = short>
operator typename identity<T>::type(); // expected-note{{candidate}}
};
int f() { return D(); } // expected-error{{no viable conversion}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match/over.match.best
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
// expected-no-diagnostics
namespace std_example {
int i;
int f1();
int&& f2();
int &g(const int &);
float &g(const int &&);
int &j = g(i);
float &k = g(f1());
float &l = g(f2());
int &g2(const int &);
float &g2(int &&);
int &j2 = g2(i);
float &k2 = g2(f1());
float &l2 = g2(f2());
// FIXME: We don't support ref-qualifiers yet.
#if 0
struct A {
A& operator<<(int);
void p() &;
void p() &&;
};
A& operator<<(A&&, char);
A() << 1;
A() << 'c';
A a;
a << 1;
a << 'c';
A().p();
a.p();
#endif
}
template<typename T>
struct remove_reference {
typedef T type;
};
template<typename T>
struct remove_reference<T&> {
typedef T type;
};
template<typename T>
struct remove_reference<T&&> {
typedef T type;
};
namespace FunctionReferencesOverloading {
template<typename T> int &f(typename remove_reference<T>::type&);
template<typename T> float &f(typename remove_reference<T>::type&&);
void test_f(int (&func_ref)(int)) {
int &ir = f<int (&)(int)>(func_ref);
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.oper
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.oper/over.literal/p7.cpp
|
// RUN: %clang_cc1 -std=c++11 %s -verify
// expected-no-diagnostics
constexpr int operator "" _a(const char *c) {
return c[0];
}
static_assert(operator "" _a("foo") == 'f', "");
void puts(const char *);
static inline void operator "" _puts(const char *c) {
puts(c);
}
void f() {
operator "" _puts("foo");
operator "" _puts("bar");
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.oper
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.oper/over.literal/p8.cpp
|
// RUN: %clang_cc1 -std=c++11 %s -verify
struct string;
namespace std {
using size_t = decltype(sizeof(int));
}
void operator "" _km(long double); // ok
string operator "" _i18n(const char*, std::size_t); // ok
template<char...> int operator "" \u03C0(); // ok, UCN for lowercase pi // expected-warning {{reserved}}
float operator ""E(const char *); // expected-error {{invalid suffix on literal}} expected-warning {{reserved}}
float operator " " B(const char *); // expected-error {{must be '""'}} expected-warning {{reserved}}
string operator "" 5X(const char *, std::size_t); // expected-error {{expected identifier}}
double operator "" _miles(double); // expected-error {{parameter}}
template<char...> int operator "" j(const char*); // expected-error {{parameter}}
float operator ""_E(const char *);
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.oper
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.oper/over.literal/p3.cpp
|
// RUN: %clang_cc1 -std=c++11 %s -verify
using size_t = decltype(sizeof(int));
// Acceptable parameter declarations
char operator "" _a(const char *);
char operator "" _a(const char []);
char operator "" _a(unsigned long long);
char operator "" _a(long double);
char operator "" _a(char);
char operator "" _a(const volatile char);
char operator "" _a(wchar_t);
char operator "" _a(char16_t);
char operator "" _a(char32_t);
char operator "" _a(const char *, size_t);
char operator "" _a(const wchar_t *, size_t);
char operator "" _a(const char16_t *, size_t);
char operator "" _a(const char32_t *, size_t);
char operator "" _a(const char [32], size_t);
// Unacceptable parameter declarations
char operator "" _b(); // expected-error {{parameter}}
char operator "" _b(const wchar_t *); // expected-error {{parameter}}
char operator "" _b(long long); // expected-error {{parameter}}
char operator "" _b(double); // expected-error {{parameter}}
char operator "" _b(short); // expected-error {{parameter}}
char operator "" _a(char, int = 0); // expected-error {{parameter}}
char operator "" _b(unsigned short); // expected-error {{parameter}}
char operator "" _b(signed char); // expected-error {{parameter}}
char operator "" _b(unsigned char); // expected-error {{parameter}}
char operator "" _b(const short *, size_t); // expected-error {{parameter}}
char operator "" _b(const unsigned short *, size_t); // expected-error {{parameter}}
char operator "" _b(const signed char *, size_t); // expected-error {{parameter}}
char operator "" _b(const unsigned char *, size_t); // expected-error {{parameter}}
char operator "" _a(const volatile char *, size_t); // expected-error {{parameter}}
char operator "" _a(volatile wchar_t *, size_t); // expected-error {{parameter}}
char operator "" _a(char16_t *, size_t); // expected-error {{parameter}}
char operator "" _a(const char32_t *, size_t, bool = false); // expected-error {{parameter}}
char operator "" _a(const char *, signed long); // expected-error {{parameter}}
char operator "" _a(const char *, size_t = 0); // expected-error {{default argument}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.oper
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.oper/over.literal/p2.cpp
|
// RUN: %clang_cc1 -std=c++11 %s -verify
void operator "" _a(const char *);
namespace N {
using ::operator "" _a;
void operator "" _b(const char *);
}
using N::operator "" _b;
class C {
void operator "" _c(const char *); // expected-error {{must be in a namespace or global scope}}
static void operator "" _c(unsigned long long); // expected-error {{must be in a namespace or global scope}}
friend void operator "" _d(const char *);
};
int operator "" _e; // expected-error {{cannot be the name of a variable}}
void f() {
int operator "" _f; // expected-error {{cannot be the name of a variable}}
}
extern "C++" {
void operator "" _g(const char *);
}
template<char...> void operator "" _h() {}
template<> void operator "" _h<'a', 'b', 'c'>() {}
template void operator "" _h<'a', 'b', 'c', 'd'>();
namespace rdar13605348 {
class C {
double operator"" _x(long double value) { return double(value); } // expected-error{{literal operator 'operator "" _x' must be in a namespace or global scope}}
double value() { return 3.2_x; } // expected-error{{no matching literal operator for call to}}
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.oper
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.oper/over.literal/p5.cpp
|
// RUN: %clang_cc1 -std=c++11 %s -verify
using size_t = decltype(sizeof(int));
template<char...> struct S {};
template<char...> void operator "" _a();
template<char... C> S<C...> operator "" _a();
template<typename T> struct U {
friend int operator "" _a(const char *, size_t);
// FIXME: It's not entirely clear whether this is intended to be legal.
friend U operator "" _a(const T *, size_t); // expected-error {{parameter}}
};
template<char...> struct V {
friend void operator "" _b(); // expected-error {{parameter}}
};
template<char... C, int N = 0> void operator "" _b(); // expected-error {{parameter}}
template<char... C> void operator "" _b(int N = 0); // expected-error {{parameter}}
template<char, char...> void operator "" _b(); // expected-error {{parameter}}
template<typename T> T operator "" _b(const char *); // expected-error {{parameter}}
template<typename T> int operator "" _b(const T *, size_t); // expected-error {{parameter}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.oper
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.oper/over.literal/p6.cpp
|
// RUN: %clang_cc1 -std=c++11 %s -verify
extern "C" void operator "" _a(const char *); // expected-error {{must have C++ linkage}}
extern "C" template<char...> void operator "" _b(); // expected-error {{must have C++ linkage}}
extern "C" {
void operator "" _c(const char *); // expected-error {{must have C++ linkage}}
template<char...> void operator "" _d(); // expected-error {{must have C++ linkage}}
namespace N {
void operator "" _e(const char *); // expected-error {{must have C++ linkage}}
template<char...> void operator "" _f(); // expected-error {{must have C++ linkage}}
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.over/p2-resolve-single-template-id.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-bool-conversion %s
typedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t;
namespace DontResolveTooEarly_WaitForOverloadResolution
{
template <class T> T* f(int); // #1
template <class T, class U> T& f(U); // #2
void g() {
int *ip = f<int>(1); // calls #1
}
template <class T>
T* f2(int);
template <class T, class U>
T& f2(U);
void g2() {
int*ip = (f2<int>)(1); // ok
}
} // End namespace
namespace DontAllowUnresolvedOverloadedExpressionInAnUnusedExpression
{
void one() { }
template<class T> void oneT() { }
void two() { } // expected-note 2 {{possible target for call}}
void two(int) { } // expected-note 2 {{possible target for call}}
template<class T> void twoT() { } // expected-note 2 {{possible target for call}}
template<class T> void twoT(T) { } // expected-note 2 {{possible target for call}}
void check()
{
one; // expected-warning {{expression result unused}}
two; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
oneT<int>; // expected-warning {{expression result unused}}
twoT<int>; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
}
// check the template function case
template<class T> void check()
{
one; // expected-warning {{expression result unused}}
two; // expected-error{{reference to overloaded function could not be resolved; did you mean to call it with no arguments?}}
oneT<int>; // expected-warning {{expression result unused}}
twoT<int>; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
}
}
template<typename T>
void twoT() { }
template<typename T, typename U>
void twoT(T) { }
void two() { }; //expected-note 5{{candidate}}
void two(int) { }; //expected-note 5{{candidate}}
void one() { }
template<class T>
void oneT() { }
template<class T>
void cant_resolve() { } //expected-note 3{{candidate}}
template<class T> void cant_resolve(T) { }//expected-note 3{{candidate}}
int main()
{
{ static_cast<void>(one); }
{ (void)(one); }
{ static_cast<void>(oneT<int>); }
{ (void)(oneT<int>); }
{ static_cast<void>(two); } // expected-error {{address of overloaded function 'two' cannot be static_cast to type 'void'}}
{ (void)(two); } // expected-error {{address of overloaded function 'two' cannot be cast to type 'void'}}
{ static_cast<void>(twoT<int>); }
{ (void)(twoT<int>); }
{ ptrdiff_t x = reinterpret_cast<ptrdiff_t>(oneT<int>); }
{ (void) reinterpret_cast<int (*)(char, double)>(oneT<int>); }
{ (void) reinterpret_cast<ptrdiff_t>(one); }
{ (void) reinterpret_cast<int (*)(char, double)>(one); }
{ ptrdiff_t x = reinterpret_cast<ptrdiff_t>(twoT<int>); }
{ (void) reinterpret_cast<int (*)(char, double)>(twoT<int>); }
{ (void) reinterpret_cast<void (*)(int)>(two); } //expected-error {{reinterpret_cast}}
{ (void) static_cast<void (*)(int)>(two); } //ok
{ (void) reinterpret_cast<int>(two); } //expected-error {{reinterpret_cast}}
{ (void) reinterpret_cast<int (*)(char, double)>(two); } //expected-error {{reinterpret_cast}}
{ bool b = (twoT<int>); }
{ bool b = (twoT<int, int>); }
{ bool b = &twoT<int>; //&foo<int>; }
b = &(twoT<int>); }
{ ptrdiff_t x = (ptrdiff_t) &twoT<int>;
x = (ptrdiff_t) &twoT<int>; }
{ ptrdiff_t x = (ptrdiff_t) twoT<int>;
x = (ptrdiff_t) twoT<int>; }
{ ptrdiff_t x = (ptrdiff_t) &twoT<int,int>;
x = (ptrdiff_t) &twoT<int>; }
{ oneT<int>; &oneT<int>; } //expected-warning 2{{expression result unused}}
{ static_cast<void>(cant_resolve<int>); } // expected-error {{address of overload}}
{ bool b = cant_resolve<int>; } // expected-error {{address of overload}}
{ (void) cant_resolve<int>; } // expected-error {{address of overload}}
}
namespace member_pointers {
struct S {
template <typename T> bool f(T) { return false; } // expected-note 4 {{possible target for call}}
template <typename T> static bool g(T) { return false; }
template <typename T> bool h(T) { return false; } // expected-note 3 {{possible target for call}}
template <int N> static bool h(int) { return false; } // expected-note 3 {{possible target for call}}
};
void test(S s) {
if (S::f<char>) return; // expected-error {{call to non-static member function without an object argument}}
if (S::f<int>) return; // expected-error {{call to non-static member function without an object argument}}
if (&S::f<char>) return;
if (&S::f<int>) return;
if (s.f<char>) return; // expected-error {{reference to non-static member function must be called}}
if (s.f<int>) return; // expected-error {{reference to non-static member function must be called}}
if (&s.f<char>) return; // expected-error {{cannot create a non-constant pointer to member function}}
if (&s.f<int>) return; // expected-error {{cannot create a non-constant pointer to member function}}
if (S::g<char>) return;
if (S::g<int>) return;
if (&S::g<char>) return;
if (&S::g<int>) return;
if (s.g<char>) return;
if (s.g<int>) return;
if (&s.g<char>) return;
if (&s.g<int>) return;
if (S::h<42>) return;
if (S::h<int>) return; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
if (&S::h<42>) return;
if (&S::h<int>) return;
if (s.h<42>) return;
if (s.h<int>) return; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
if (&s.h<42>) return;
if (&s.h<int>) return; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
{ bool b = S::f<char>; } // expected-error {{call to non-static member function without an object argument}}
{ bool b = S::f<int>; } // expected-error {{call to non-static member function without an object argument}}
{ bool b = &S::f<char>; }
{ bool b = &S::f<int>; }
// These next two errors are terrible.
{ bool b = s.f<char>; } // expected-error {{reference to non-static member function must be called}}
{ bool b = s.f<int>; } // expected-error {{reference to non-static member function must be called}}
{ bool b = &s.f<char>; } // expected-error {{cannot create a non-constant pointer to member function}}
{ bool b = &s.f<int>; } // expected-error {{cannot create a non-constant pointer to member function}}
{ bool b = S::g<char>; }
{ bool b = S::g<int>; }
{ bool b = &S::g<char>; }
{ bool b = &S::g<int>; }
{ bool b = s.g<char>; }
{ bool b = s.g<int>; }
{ bool b = &s.g<char>; }
{ bool b = &s.g<int>; }
{ bool b = S::h<42>; }
{ bool b = S::h<int>; } // expected-error {{can't form member pointer of type 'bool' without '&' and class name}}
{ bool b = &S::h<42>; }
{ bool b = &S::h<int>; }
{ bool b = s.h<42>; }
{ bool b = s.h<int>; } // expected-error {{can't form member pointer of type 'bool' without '&' and class name}}
{ bool b = &s.h<42>; }
{ bool b = &s.h<int>; } // expected-error {{can't form member pointer of type 'bool' without '&' and class name}}
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.over/p4.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
template<typename T> T f0(T); // expected-note{{candidate function}}
int f0(int); // expected-note{{candidate function}}
void test_f0() {
int (*fp0)(int) = f0;
int (*fp1)(int) = &f0;
float (*fp2)(float) = &f0;
}
namespace N {
int f0(int); // expected-note{{candidate function}}
}
void test_f0_2() {
using namespace N;
int (*fp0)(int) = f0; // expected-error{{address of overloaded function 'f0' is ambiguous}}
float (*fp1)(float) = f0;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.over/p2.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
template <typename T>
T f0(T, T); // expected-note{{deduced conflicting types for parameter 'T' ('int' vs. 'float')}}
void test_f0() {
int (*f0a)(int, int) = f0;
int (*f0b)(int, int) = &f0;
int (*f0c)(int, float) = f0; // expected-error{{address of overloaded function 'f0' does not match required type 'int (int, float)'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.over/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only %s
template<typename T> T f0(T);
int f0(int);
// -- an object or reference being initialized
struct S {
int (*f0)(int);
float (*f1)(float);
};
void test_init_f0() {
int (*f0a)(int) = f0;
int (*f0b)(int) = &f0;
int (*f0c)(int) = (f0);
float (*f0d)(float) = f0;
float (*f0e)(float) = &f0;
float (*f0f)(float) = (f0);
int (&f0g)(int) = f0;
int (&f0h)(int) = (f0);
float (&f0i)(float) = f0;
float (&f0j)(float) = (f0);
S s = { f0, f0 };
}
// -- the left side of an assignment (5.17),
void test_assign_f0() {
int (*f0a)(int) = 0;
float (*f0b)(float) = 0;
f0a = f0;
f0a = &f0;
f0a = (f0);
f0b = f0;
f0b = &f0;
f0b = (f0);
}
// -- a parameter of a function (5.2.2),
void eat_f0(int a(int), float (*b)(float), int (&c)(int), float (&d)(float));
void test_pass_f0() {
eat_f0(f0, f0, f0, f0);
eat_f0(&f0, &f0, (f0), (f0));
}
// -- a parameter of a user-defined operator (13.5),
struct X { };
void operator+(X, int(int));
void operator-(X, float(*)(float));
void operator*(X, int (&)(int));
void operator/(X, float (&)(float));
void test_operator_pass_f0(X x) {
x + f0;
x + &f0;
x - f0;
x - &f0;
x * f0;
x * (f0);
x / f0;
x / (f0);
}
// -- the return value of a function, operator function, or conversion (6.6.3),
int (*test_return_f0_a())(int) { return f0; }
int (*test_return_f0_b())(int) { return &f0; }
int (*test_return_f0_c())(int) { return (f0); }
float (*test_return_f0_d())(float) { return f0; }
float (*test_return_f0_e())(float) { return &f0; }
float (*test_return_f0_f())(float) { return (f0); }
// -- an explicit type conversion (5.2.3, 5.2.9, 5.4), or
void test_convert_f0() {
(void)((int (*)(int))f0);
(void)((int (*)(int))&f0);
(void)((int (*)(int))(f0));
(void)((float (*)(float))f0);
(void)((float (*)(float))&f0);
(void)((float (*)(float))(f0));
}
// -- a non-type template-parameter(14.3.2).
template<int(int)> struct Y0 { };
template<float(float)> struct Y1 { };
template<int (&)(int)> struct Y2 { };
template<float (&)(float)> struct Y3 { };
Y0<f0> y0;
Y0<&f0> y0a;
Y1<f0> y1;
Y1<&f0> y1a;
Y2<f0> y2;
Y3<f0> y3;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/over
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/over/over.load/p2-0x.cpp
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
// Member function declarations with the same name and the same
// parameter-type-list as well as mem- ber function template
// declarations with the same name, the same parameter-type-list, and
// the same template parameter lists cannot be overloaded if any of
// them, but not all, have a ref-qualifier (8.3.5).
class Y {
void h() &;
void h() const &;
void h() &&;
void i() &; // expected-note{{previous declaration}}
void i() const; // expected-error{{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}}
template<typename T> void f(T*) &;
template<typename T> void f(T*) &&;
template<typename T> void g(T*) &; // expected-note{{previous declaration}}
template<typename T> void g(T*); // expected-error{{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}}
void k(); // expected-note{{previous declaration}}
void k() &&; // expected-error{{cannot overload a member function with ref-qualifier '&&' with a member function without a ref-qualifier}}
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/p2-0x.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
namespace Test1 {
class A final { }; // expected-note {{'A' declared here}}
class B : A { }; // expected-error {{base 'A' is marked 'final'}}
}
namespace Test2 {
template<typename T> struct A final { }; // expected-note 2 {{'A' declared here}}
struct B : A<int> { }; // expected-error {{base 'A' is marked 'final'}}
template<typename T> struct C : A<T> { }; // expected-error {{base 'A' is marked 'final'}}
struct D : C<int> { }; // expected-note {{in instantiation of template class 'Test2::C<int>' requested here}}
}
namespace Test3 {
template<typename T> struct A { };
template<> struct A<int> final { }; // expected-note {{'A' declared here}}
struct B : A<bool> { };
struct C : A<int> { }; // expected-error {{base 'A' is marked 'final'}}
}
namespace Test4 {
struct A final { virtual void func() = 0; }; // expected-warning {{abstract class is marked 'final'}} expected-note {{unimplemented pure virtual method 'func' in 'A'}}
struct B { virtual void func() = 0; }; // expected-note {{unimplemented pure virtual method 'func' in 'C'}}
struct C final : B { }; // expected-warning {{abstract class is marked 'final'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/p6-0x.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
// expected-no-diagnostics
class Trivial { int n; void f(); };
class NonTrivial1 { NonTrivial1(const NonTrivial1 &); };
class NonTrivial2 { NonTrivial2(NonTrivial2 &&); };
class NonTrivial3 { NonTrivial3 operator=(const NonTrivial3 &); };
class NonTrivial4 { NonTrivial4 operator=(NonTrivial4 &&); };
class NonTrivial5 { ~NonTrivial5(); };
static_assert(__is_trivial(Trivial), "Trivial is not trivial");
static_assert(!__is_trivial(NonTrivial1), "NonTrivial1 is trivial");
static_assert(!__is_trivial(NonTrivial2), "NonTrivial2 is trivial");
static_assert(!__is_trivial(NonTrivial3), "NonTrivial3 is trivial");
static_assert(!__is_trivial(NonTrivial4), "NonTrivial4 is trivial");
static_assert(!__is_trivial(NonTrivial5), "NonTrivial5 is trivial");
struct Trivial2 {
Trivial2() = default;
Trivial2(const Trivial2 &) = default;
Trivial2(Trivial2 &&) = default;
Trivial2 &operator=(const Trivial2 &) = default;
Trivial2 &operator=(Trivial2 &&) = default;
~Trivial2() = default;
};
class NonTrivial6 { ~NonTrivial6(); };
NonTrivial6::~NonTrivial6() = default;
static_assert(!__is_trivial(NonTrivial6), "NonTrivial6 is trivial");
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/p1-0x.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
// expected-no-diagnostics
namespace Test1 {
class A final { };
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.nested.type/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
class X {
public:
typedef int I; // expected-note{{'X::I' declared here}}
class Y { }; // expected-note{{'X::Y' declared here}}
I a;
};
I b; // expected-error{{unknown type name 'I'; did you mean 'X::I'?}}
Y c; // expected-error{{unknown type name 'Y'; did you mean 'X::Y'?}}
X::Y d;
X::I e;
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.base
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.base/class.base.init/p5-0x.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// [class.base.init]p5
// A ctor-initializer may initialize a variant member of the constructor’s
// class. If a ctor-initializer specifies more than one mem-initializer for the
// same member or for the same base class, the ctor-initializer is ill-formed.
union E {
int a;
int b;
E() : a(1), // expected-note{{previous initialization is here}}
b(2) { // expected-error{{initializing multiple members of union}}
}
};
union F {
struct {
int a;
int b;
};
int c;
F() : a(1), // expected-note{{previous initialization is here}}
b(2),
c(3) { // expected-error{{initializing multiple members of union}}
}
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.union/p2-0x.cpp
|
// RUN: %clang_cc1 -verify -std=c++11 %s
// Unlike in C++98, C++11 allows unions to have static data members.
union U1 {
static constexpr int k1 = 0;
static const int k2 = k1;
static int k3 = k2; // expected-error {{non-const static data member must be initialized out of line}}
static constexpr double k4 = k2;
static const double k5 = k4; // expected-error {{requires 'constexpr' specifier}} expected-note {{add 'constexpr'}}
int n[k1 + 3];
};
constexpr int U1::k1;
constexpr int U1::k2;
int U1::k3;
const double U1::k4;
const double U1::k5;
template<typename T>
union U2 {
static const int k1;
static double k2;
T t;
};
template<typename T> constexpr int U2<T>::k1 = sizeof(U2<T>);
template<typename T> double U2<T>::k2 = 5.3;
static_assert(U2<int>::k1 == sizeof(int), "");
static_assert(U2<char>::k1 == sizeof(char), "");
union U3 {
static const int k;
U3() : k(0) {} // expected-error {{does not name a non-static data member}}
};
struct S {
union {
static const int n; // expected-error {{static members cannot be declared in an anonymous union}}
int a;
int b;
};
};
static union {
static const int k; // expected-error {{static members cannot be declared in an anonymous union}}
int n;
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.union/p8.cpp
|
// RUN: %clang_cc1 -std=c++11 -verify %s
union U {
int x = 0; // expected-note {{previous initialization is here}}
union {};
union {
int z;
int y = 1; // expected-error {{initializing multiple members of union}}
};
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.union/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
void abort() __attribute__((noreturn));
class Okay {
int a_;
};
class Virtual {
virtual void foo() { abort(); } // expected-note 4 {{because type 'Virtual' has a virtual member function}}
};
class VirtualBase : virtual Okay { // expected-note 4 {{because type 'VirtualBase' has a virtual base class}}
};
class Ctor {
Ctor() { abort(); } // expected-note 2{{because type 'Ctor' has a user-provided default constructor}} expected-note 2{{here}}
};
class Ctor2 {
Ctor2(); // expected-note {{because type 'Ctor2' has a user-provided default constructor}} expected-note 2{{here}}
};
class CtorTmpl { // expected-note {{because type 'CtorTmpl' has no default constructor}}
template<typename T> CtorTmpl(); // expected-note {{implicit default constructor suppressed by user-declared constructor}}
};
class CopyCtor { // expected-note 2{{because no constructor can be used to copy an object of type 'const CopyCtor'}}
CopyCtor(CopyCtor &cc) { abort(); }
};
class CopyAssign { // expected-note 2 {{because no assignment operator can be used to copy an object of type 'const CopyAssign'}}
CopyAssign& operator=(CopyAssign& CA) { abort(); }
};
class Dtor {
~Dtor() { abort(); } // expected-note 2 {{because type 'Dtor' has a user-provided destructor}} expected-note 2{{here}}
};
union U1 {
Virtual v; // expected-error {{union member 'v' has a non-trivial copy constructor}}
VirtualBase vbase; // expected-error {{union member 'vbase' has a non-trivial copy constructor}}
Ctor ctor; // expected-error {{union member 'ctor' has a non-trivial constructor}}
Ctor2 ctor2; // expected-error {{union member 'ctor2' has a non-trivial constructor}}
CtorTmpl ctortmpl; // expected-error {{union member 'ctortmpl' has a non-trivial constructor}}
CopyCtor copyctor; // expected-error {{union member 'copyctor' has a non-trivial copy constructor}}
CopyAssign copyassign; // expected-error {{union member 'copyassign' has a non-trivial copy assignment operator}}
Dtor dtor; // expected-error {{union member 'dtor' has a non-trivial destructor}}
Okay okay;
};
union U2 {
struct {
Virtual v; // expected-note {{because the function selected to copy field of type 'Virtual' is not trivial}}
} m1; // expected-error {{union member 'm1' has a non-trivial copy constructor}}
struct {
VirtualBase vbase; // expected-note {{because the function selected to copy field of type 'VirtualBase' is not trivial}}
} m2; // expected-error {{union member 'm2' has a non-trivial copy constructor}}
struct {
Ctor ctor; // expected-note {{because field of type 'Ctor' has a user-provided default constructor}}
} m3; // expected-error {{union member 'm3' has a non-trivial constructor}}
struct {
Ctor2 ctor2; // expected-note {{because field of type 'Ctor2' has a user-provided default constructor}}
} m3a; // expected-error {{union member 'm3a' has a non-trivial constructor}}
struct { // expected-note {{no constructor can be used to copy an object of type 'const}}
CopyCtor copyctor;
} m4; // expected-error {{union member 'm4' has a non-trivial copy constructor}}
struct { // expected-note {{no assignment operator can be used to copy an object of type 'const}}
CopyAssign copyassign;
} m5; // expected-error {{union member 'm5' has a non-trivial copy assignment operator}}
struct {
Dtor dtor; // expected-note {{because field of type 'Dtor' has a user-provided destructor}}
} m6; // expected-error {{union member 'm6' has a non-trivial destructor}}
struct {
Okay okay;
} m7;
};
union U3 {
struct s1 : Virtual { // expected-note {{because the function selected to copy base class of type 'Virtual' is not trivial}}
} m1; // expected-error {{union member 'm1' has a non-trivial copy constructor}}
struct s2 : VirtualBase { // expected-note {{because the function selected to copy base class of type 'VirtualBase' is not trivial}}
} m2; // expected-error {{union member 'm2' has a non-trivial copy constructor}}
struct s3 : Ctor { // expected-note {{because base class of type 'Ctor' has a user-provided default constructor}}
} m3; // expected-error {{union member 'm3' has a non-trivial constructor}}
struct s3a : Ctor2 { // expected-note {{because base class of type 'Ctor2' has a user-provided default constructor}}
} m3a; // expected-error {{union member 'm3a' has a non-trivial constructor}}
struct s4 : CopyCtor { // expected-note {{because no constructor can be used to copy an object of type 'const U3::s4'}}
} m4; // expected-error {{union member 'm4' has a non-trivial copy constructor}}
struct s5 : CopyAssign { // expected-note {{because no assignment operator can be used to copy an object of type 'const U3::s5'}}
} m5; // expected-error {{union member 'm5' has a non-trivial copy assignment operator}}
struct s6 : Dtor { // expected-note {{because base class of type 'Dtor' has a user-provided destructor}}
} m6; // expected-error {{union member 'm6' has a non-trivial destructor}}
struct s7 : Okay {
} m7;
struct s8 {
s8(...) = delete; // expected-note {{because it is a variadic function}} expected-warning {{C++11}}
} m8; // expected-error {{union member 'm8' has a non-trivial constructor}}
};
union U4 {
static int i1; // expected-warning {{static data member 'i1' in union is a C++11 extension}}
};
int U4::i1 = 10;
union U5 {
int& i1; // expected-error {{union member 'i1' has reference type 'int &'}}
};
union U6 {
struct S {
int &i;
} s; // ok
};
template <class A, class B> struct Either {
bool tag;
union { // expected-note 6 {{in instantiation of member class}}
A a;
B b; // expected-error 6 {{non-trivial}}
};
Either(const A& a) : tag(true), a(a) {}
Either(const B& b) : tag(false), b(b) {}
};
void fred() {
Either<int,Virtual> virt(0); // expected-note {{in instantiation of template}}
Either<int,VirtualBase> vbase(0); // expected-note {{in instantiation of template}}
Either<int,Ctor> ctor(0); // expected-note {{in instantiation of template}}
Either<int,CopyCtor> copyctor(0); // expected-note {{in instantiation of template}}
Either<int,CopyAssign> copyassign(0); // expected-note {{in instantiation of template}}
Either<int,Dtor> dtor(0); // expected-note {{in instantiation of template}}
Either<int,Okay> okay(0);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.static
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.static/class.static.data/p4.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct InClassInitializerOnly {
static const int i = 0;
};
int const InClassInitializerOnly::i;
struct OutOfClassInitializerOnly {
static const int i;
};
int const OutOfClassInitializerOnly::i = 0;
struct InClassInitializerAndOutOfClassCopyInitializer {
static const int i = 0; // expected-note{{previous initialization is here}}
};
int const InClassInitializerAndOutOfClassCopyInitializer::i = 0; // expected-error{{static data member 'i' already has an initializer}}
struct InClassInitializerAndOutOfClassDirectInitializer {
static const int i = 0; // expected-note{{previous initialization is here}}
};
int const InClassInitializerAndOutOfClassDirectInitializer::i(0); // expected-error{{static data member 'i' already has an initializer}}
int main() { }
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.static
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.static/class.static.data/p3.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
struct NonLit { // expected-note 3{{no constexpr constructors}}
NonLit();
};
struct S {
static constexpr int a = 0;
static constexpr int b; // expected-error {{declaration of constexpr static data member 'b' requires an initializer}}
static constexpr int c = 0;
static const int d;
static const int d2 = 0;
static constexpr double e = 0.0; // ok
static const double f = 0.0; // expected-error {{requires 'constexpr' specifier}} expected-note {{add 'constexpr'}}
static char *const g = 0; // expected-error {{requires 'constexpr' specifier}}
static const NonLit h = NonLit(); // expected-error {{must be initialized out of line}}
};
constexpr int S::a;
constexpr int S::b = 0;
const int S::c;
constexpr int S::d = 0;
constexpr int S::d2;
template<typename T>
struct U {
static constexpr int a = 0;
static constexpr int b; // expected-error {{declaration of constexpr static data member 'b' requires an initializer}}
static constexpr NonLit h = NonLit(); // expected-error {{cannot have non-literal type 'const NonLit'}}
static constexpr T c = T(); // expected-error {{cannot have non-literal type}}
static const T d;
};
template<typename T> constexpr T U<T>::d = T(); // expected-error {{non-literal type 'const NonLit'}}
U<int> u1;
U<NonLit> u2; // expected-note {{here}}
static_assert(U<int>::a == 0, "");
constexpr int outofline = (U<NonLit>::d, 0); // expected-note {{here}} expected-warning {{unused}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.mfct
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// [class.mfct.non-static]p3:
// When an id-expression (5.1) that is not part of a class member
// access syntax (5.2.5) and not used to form a pointer to member
// (5.3.1) is used in the body of a non-static member function of
// class X, if name lookup (3.4.1) resolves the name in the
// id-expression to a non-static non-type member of some class C,
// the id-expression is transformed into a class member access
// expression (5.2.5) using (*this) (9.3.2) as the
// postfix-expression to the left of the . operator. [ Note: if C is
// not X or a base class of X, the class member access expression is
// ill-formed. --end note] Similarly during name lookup, when an
// unqualified-id (5.1) used in the definition of a member function
// for class X resolves to a static member, an enumerator or a
// nested type of class X or of a base class of X, the
// unqualified-id is transformed into a qualified-id (5.1) in which
// the nested-name-specifier names the class of the member function.
namespace test0 {
class A {
int data_member;
int instance_method();
static int static_method();
bool test() {
return data_member + instance_method() < static_method();
}
};
}
namespace test1 {
struct Opaque1 {}; struct Opaque2 {}; struct Opaque3 {};
struct A {
void foo(Opaque1); // expected-note {{candidate}}
void foo(Opaque2); // expected-note {{candidate}}
};
struct B : A {
void test();
};
struct C1 : A { };
struct C2 : B { };
void B::test() {
A::foo(Opaque1());
A::foo(Opaque2());
A::foo(Opaque3()); // expected-error {{no matching member function}}
C1::foo(Opaque1()); // expected-error {{call to non-static member function without an object argument}}
C2::foo(Opaque1()); // expected-error {{call to non-static member function without an object argument}}
}
}
namespace test2 {
struct Unrelated {
void foo();
};
template <class T> struct B;
template <class T> struct C;
template <class T> struct A {
void foo();
void test0() {
Unrelated::foo(); // expected-error {{call to non-static member function without an object argument}}
}
void test1() {
B<T>::foo();
}
static void test2() {
B<T>::foo(); // expected-error {{call to non-static member function without an object argument}}
}
void test3() {
C<T>::foo(); // expected-error {{no member named 'foo'}}
}
};
template <class T> struct B : A<T> {
};
template <class T> struct C {
};
int test() {
A<int> a;
a.test0(); // no instantiation note here, decl is ill-formed
a.test1();
a.test2(); // expected-note {{in instantiation}}
a.test3(); // expected-note {{in instantiation}}
}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.mem/p8-0x.cpp
|
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
struct Base1 {
virtual void g();
};
struct A : Base1 {
virtual void g() override override; // expected-error {{class member already marked 'override'}}
virtual void h() final final; // expected-error {{class member already marked 'final'}}
};
struct Base2 {
virtual void e1(), e2();
virtual void f();
};
struct B : Base2 {
virtual void e1() override, e2(int); // No error.
virtual void f() override;
void g() override; // expected-error {{only virtual member functions can be marked 'override'}}
int h override; // expected-error {{only virtual member functions can be marked 'override'}}
};
struct C {
virtual void f() final;
void g() final; // expected-error {{only virtual member functions can be marked 'final'}}
int h final; // expected-error {{only virtual member functions can be marked 'final'}}
};
namespace inline_extension {
struct Base1 {
virtual void g() {}
};
struct A : Base1 {
virtual void g() override override {} // expected-error {{class member already marked 'override'}}
virtual void h() final final {} // expected-error {{class member already marked 'final'}}
};
struct Base2 {
virtual void f();
};
struct B : Base2 {
virtual void f() override {}
void g() override {} // expected-error {{only virtual member functions can be marked 'override'}}
};
struct C {
virtual void f() final {}
void g() final {} // expected-error {{only virtual member functions can be marked 'final'}}
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.mem/p14.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// In addition, if class T has a user-declared constructor (12.1),
// every non-static data member of class T shall have a name different
// from T.
struct X0 {
int X0; // okay
};
struct X1 {
int X1; // expected-note{{hidden by a non-type declaration of 'X1' here}}
X1(); // expected-error{{must use 'struct' tag to refer to type 'X1' in this scope}} \
// expected-error{{expected member name or ';' after declaration specifiers}}
};
struct X2 {
X2();
float X2; // expected-error{{member 'X2' has the same name as its class}}
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.mem/p5-0x.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
int f();
struct S
{
int a = f(); // ok
int b = g(); // expected-error {{use of undeclared identifier 'g'}}
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.mem/p13.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
// If T is the name of a class, then each of the following shall have
// a name different from T:
// - every static data member of class T;
struct X0 {
static int X0; // expected-error{{member 'X0' has the same name as its class}}
};
// - every member function of class T
struct Xa {
int Xa() {} // expected-error{{constructor cannot have a return type}}
};
// - every member of class T that is itself a type;
struct X1 {
enum X1 { }; // expected-error{{member 'X1' has the same name as its class}}
};
struct X1a {
struct X1a; // expected-error{{member 'X1a' has the same name as its class}}
};
struct X2 {
typedef int X2; // expected-error{{member 'X2' has the same name as its class}}
};
struct X2a {
using X2a = int; // expected-error{{member 'X2a' has the same name as its class}}
};
// - every member template of class T
struct X2b {
template<typename T> struct X2b; // expected-error{{member 'X2b' has the same name as its class}}
};
struct X2c {
template<typename T> void X2c(); // expected-error{{constructor cannot have a return type}}
};
struct X2d {
template<typename T> static int X2d; // expected-error{{member 'X2d' has the same name as its class}}
};
struct X2e {
template<typename T> using X2e = int; // expected-error{{member 'X2e' has the same name as its class}}
};
// - every enumerator of every member of class T that is an unscoped enumerated type; and
struct X3 {
enum E {
X3 // expected-error{{member 'X3' has the same name as its class}}
};
};
struct X3a {
enum class E {
X3a // ok
};
};
// - every member of every anonymous union that is a member of class T.
struct X4 {
union {
int X;
union {
float Y;
unsigned X4; // expected-error{{member 'X4' has the same name as its class}}
};
};
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.mem/p2.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// C++11 [class.mem]p2:
// A class is considered a completely-defined object type (or
// complete type) at the closing } of the class-specifier. Within
// the class member-specification, the class is regarded as complete
// within function bodies, default arguments,
// exception-specifications, and brace-or-equal-initializers for
// non-static data members (including such things in nested classes).
// Otherwise it is regarded as incomplete within its own class
// member-specification.
namespace test0 {
struct A { // expected-note {{definition of 'test0::A' is not complete until the closing '}'}}
A x; // expected-error {{field has incomplete type 'test0::A'}}
};
}
namespace test1 {
template <class T> struct A {
A<int> x; // expected-error {{implicit instantiation of template 'test1::A<int>' within its own definition}}
};
}
namespace test2 {
template <class T> struct A;
template <> struct A<int> {};
template <class T> struct A {
A<int> x;
};
}
namespace test3 {
struct A {
struct B {
void f() throw(A);
void g() throw(B);
};
void f() throw(A);
void g() throw(B);
};
template<typename T>
struct A2 {
struct B {
void f1() throw(A2);
void f2() throw(A2<T>);
void g() throw(B);
};
void f1() throw(A2);
void f2() throw(A2<T>);
void g() throw(B);
};
template struct A2<int>;
}
namespace PR12629 {
struct S {
static int (f)() throw();
static int ((((((g))))() throw(U)));
int (*h)() noexcept(false);
static int (&i)() noexcept(true);
static int (*j)() throw(U); // expected-error {{unknown type name 'U'}}
static int (k)() throw(U);
struct U {};
};
static_assert(noexcept(S::f()), "");
static_assert(!noexcept(S::g()), "");
static_assert(!noexcept(S().h()), "");
static_assert(noexcept(S::i()), "");
}
namespace PR12688 {
struct S {
// FIXME: Maybe suppress the "constructor cannot have a return type" error
// if the return type is invalid.
nonsense S() throw (more_nonsense); // \
// expected-error {{'nonsense'}} \
// expected-error {{constructor cannot have a return type}}
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.mem/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct S
{
static int v1; // expected-note{{previous declaration is here}}
int v1; //expected-error{{duplicate member 'v1'}}
int v; //expected-note 2{{previous definition is here}} \
// expected-note{{previous declaration is here}}
static int v; //expected-error{{redefinition of 'v' as different kind of symbol}}
int v; //expected-error{{duplicate member 'v'}}
static int v; //expected-error{{redefinition of 'v' as different kind of symbol}}
enum EnumT { E = 10 };
friend struct M;
struct X; //expected-note{{forward declaration of 'S::X'}}
friend struct X;
};
S::EnumT Evar = S::E; // ok
S::EnumT Evar2 = EnumT(); //expected-error{{use of undeclared identifier 'EnumT'}}
S::M m; //expected-error{{no type named 'M' in 'S'}}
S::X x; //expected-error{{variable has incomplete type 'S::X'}}
struct S2
{
static int v2; // expected-note{{previous declaration is here}}
static int v2; //expected-error{{duplicate member 'v2'}}
};
struct S3
{
static int v3;
struct S4
{
static int v3;
};
};
struct S4
{
static int v4;
};
int S4::v4; //expected-note{{previous definition is here}}
int S4::v4; //expected-error{{redefinition of 'v4'}}
struct S5
{
static int v5; //expected-note{{previous definition is here}}
void v5() { } //expected-error{{redefinition of 'v5' as different kind of symbol}}
void v6() { } //expected-note{{previous definition is here}}
static int v6; //expected-error{{redefinition of 'v6' as different kind of symbol}}
void v7() { }
void v7(int) { } //expected-note{{previous definition is here}}
static int v7; //expected-error{{redefinition of 'v7' as different kind of symbol}}
void v8();
int v8(int); //expected-note{{previous declaration is here}}
int v8; //expected-error{{duplicate member 'v8'}}
};
namespace PR8245 {
class X {
public:
template<class C>
class Inner {
public:
void foo(bool bar = true);
int bam;
};
Inner<int> _foo;
};
void f() {
X::Inner<int> c2i;
X::Inner<float> c2f;
c2i.foo();
c2f.foo();
}
class Y {
class Inner {
void foo(int = sizeof(Y));
};
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.mem/p1b.cpp
|
// The first run checks that the correct errors are generated,
// implicitly checking the order of default argument parsing:
// RUN: %clang_cc1 -fsyntax-only -verify %s
// The second run checks the order of inline method definitions:
// RUN: not %clang_cc1 -fsyntax-only %s 2> %t
// RUN: FileCheck %s < %t
class A {
public:
void a1() {
B b = B();
}
class B;
void a2(B b = B()); // expected-error{{use of default argument to function 'B' that is declared later in class 'B'}}
void a3(int a = 42);
// CHECK: error: use of undeclared identifier 'first'
void a4(int a = first); // expected-error{{use of undeclared identifier 'first'}}
class B {
public:
B(int b = 42) { // expected-note{{default argument declared here}}
A a;
a.a3();
a.a6();
}
void b1(A a = A()); // expected-error{{use of default argument to function 'A' that is declared later in class 'A'}}
// CHECK: error: use of undeclared identifier 'second'
void b2(int a = second); // expected-error{{use of undeclared identifier 'second'}}
};
void a5() {
B b = B();
}
void a6(B b = B());
A(int a = 42); // expected-note{{default argument declared here}}
// CHECK: error: use of undeclared identifier 'third'
void a7(int a = third); // expected-error{{use of undeclared identifier 'third'}}
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.friend/p1-cxx11.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// expected-no-diagnostics
class A {
class AInner {
};
void a_member();
friend void A::a_member(); // ok in c++11, ill-formed in c++98
friend void a_member(); // ok in both, refers to non-member
friend class A::AInner; // ok in c++11, extension in c++98
friend class AInner; // ok in both, refers to non-member
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.friend/p2.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct B0;
class A {
friend class B {}; // expected-error {{cannot define a type in a friend declaration}}
friend int; // expected-warning {{non-class friend type 'int' is a C++11 extension}}
friend B0; // expected-warning {{specify 'struct' to befriend 'B0'}}
friend class C; // okay
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.friend/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct Outer {
struct Inner {
int intfield;
};
};
struct Base {
void base_member();
typedef int Int;
Int typedeffed_member();
};
struct Derived : public Base {
};
int myglobal;
void global_function();
extern "C" {
void global_c_function();
}
class A {
class AInner {
};
friend class PreDeclared;
friend class Outer::Inner;
friend int Outer::Inner::intfield; // expected-error {{friends can only be classes or functions}}
friend int Outer::Inner::missing_field; //expected-error {{friends can only be classes or functions}}
friend int myoperation(float); // okay
friend int myglobal; // expected-error {{friends can only be classes or functions}}
friend void global_function();
friend void global_c_function();
friend class UndeclaredSoFar;
UndeclaredSoFar x; // expected-error {{unknown type name 'UndeclaredSoFar'}}
void a_member();
friend void A::a_member(); // expected-error {{friends cannot be members of the declaring class}}
friend void a_member(); // okay (because we ignore class scopes when looking up friends)
friend class A::AInner; // this is okay as an extension
friend class AInner; // okay, refers to ::AInner
friend void Derived::missing_member(); // expected-error {{no function named 'missing_member' with type 'void ()' was found in the specified scope}}
friend void Derived::base_member(); // expected-error {{no function named 'base_member' with type 'void ()' was found in the specified scope}}
friend int Base::typedeffed_member(); // okay: should look through typedef
// These test that the friend is properly not being treated as a
// member function.
friend A operator|(const A& l, const A& r); // okay
friend A operator|(const A& r); // expected-error {{overloaded 'operator|' must be a binary operator (has 1 parameter)}}
friend operator bool() const; // expected-error {{must use a qualified name when declaring a conversion operator as a friend}} \
// expected-error{{non-member function cannot have 'const' qualifier}}
typedef void ftypedef();
friend ftypedef typedeffed_function; // okay (because it's not declared as a member)
class facet;
friend class facet; // should not assert
class facet {};
friend int Unknown::thing(); // expected-error {{use of undeclared identifier}}
friend int friendfunc(), Unknown::thing(); // expected-error {{use of undeclared identifier}}
friend int friendfunc(), Unknown::thing() : 4; // expected-error {{use of undeclared identifier}}
};
A::UndeclaredSoFar y; // expected-error {{no type named 'UndeclaredSoFar' in 'A'}}
class PreDeclared;
int myoperation(float f) {
return (int) f;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.friend/p1-ambiguous.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
// Make sure that friend declarations don't introduce ambiguous
// declarations.
// Test case courtesy of Shantonu Sen.
// Bug 4784.
class foo;
extern "C" {
int c_func(foo *a);
};
int cpp_func(foo *a);
class foo {
public:
friend int c_func(foo *a);
friend int cpp_func(foo *a);
int caller();
private:
int x;
};
int c_func(foo *a) {
return a->x;
}
int cpp_func(foo *a) {
return a->x;
}
int foo::caller() {
c_func(this);
cpp_func(this);
return 0;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.friend/p6.cpp
|
// RUN: %clang_cc1 -fsyntax-only -Wc++11-compat -verify -std=c++98 %s
// RUN: %clang_cc1 -fsyntax-only -Wc++11-compat -verify -std=c++11 %s
class A {
friend static class B; // expected-error {{'static' is invalid in friend declarations}}
friend extern class C; // expected-error {{'extern' is invalid in friend declarations}}
#if __cplusplus < 201103L
friend register class E; // expected-error {{'register' is invalid in friend declarations}}
#else
friend register class E; // expected-error {{'register' is invalid in friend declarations}}
#endif
friend mutable class F; // expected-error {{'mutable' is invalid in friend declarations}}
friend typedef class G; // expected-error {{'typedef' is invalid in friend declarations}}
friend __thread class G; // expected-error {{'__thread' is invalid in friend declarations}}
friend _Thread_local class G; // expected-error {{'_Thread_local' is invalid in friend declarations}}
friend static _Thread_local class G; // expected-error {{'static _Thread_local' is invalid in friend declarations}}
#if __cplusplus < 201103L
friend auto class D; // expected-warning {{incompatible with C++11}} expected-error {{'auto' is invalid in friend declarations}}
#else
friend thread_local class G; // expected-error {{'thread_local' is invalid in friend declarations}}
#endif
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.bit/p2.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
struct A {
private:
int : 0;
};
A a = { };
A a2 = { 1 }; // expected-error{{excess elements in struct initializer}}
struct B {
const int : 0;
};
B b;
void testB() {
B b2(b);
B b3(static_cast<B&&>(b2));
b = b;
b = static_cast<B&&>(b);
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.local/p4.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
void f() {
struct X {
static int a; // expected-error {{static data member 'a' not allowed in local class 'X'}}
int b;
static void f() { }
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.local/p3.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
void f1() {
struct X {
struct Y;
};
struct X::Y {
void f() {}
};
}
void f2() {
struct X {
struct Y;
struct Y {
void f() {}
};
};
}
// A class nested within a local class is a local class.
void f3(int a) { // expected-note{{'a' declared here}}
struct X {
struct Y {
int f() { return a; } // expected-error{{reference to local variable 'a' declared in enclosing function 'f3'}}
};
};
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.local/p2.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct A { };
void f() {
struct B : private A {}; // expected-note{{declared private here}}
B b;
A *a = &b; // expected-error{{cannot cast 'B' to its private base class 'A'}}
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.local/p1-0x.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
void f() {
int x = 3; // expected-note{{'x' declared here}}
const int c = 2;
struct C {
int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing function 'f'}}
int cc = c;
};
(void)[]() mutable {
int x = 3; // expected-note{{'x' declared here}}
struct C {
int& x2 = x; // expected-error{{reference to local variable 'x' declared in enclosing lambda expression}}
};
};
C();
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.local/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
int x;
void f()
{
static int s;
int x; // expected-note{{'x' declared here}}
extern int g();
struct local {
int g() { return x; } // expected-error{{reference to local variable 'x' declared in enclosing function 'f'}}
int h() { return s; }
int k() { return :: x; }
int l() { return g(); }
};
}
local* p = 0; // expected-error{{unknown type name 'local'}}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.nest/p1-cxx0x.cpp
|
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
class Outer {
int x;
static int sx;
int f();
// The first case is invalid in the C++03 mode but valid in C++0x (see 5.1.1.10).
class Inner {
static char a[sizeof(x)]; // okay
static char b[sizeof(sx)]; // okay
static char c[sizeof(f)]; // expected-error {{call to non-static member function without an object argument}}
};
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.nest/p3.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
// C++0x [class.nest] p3:
// If class X is defined in a namespace scope, a nested class Y may be
// declared in class X and later defined in the definition of class X or be
// later defined in a namespace scope enclosing the definition of class X.
namespace example {
class E {
class I1;
class I2;
class I1 { };
};
class E::I2 { };
}
// Don't insert out-of-line inner class definitions into the namespace scope.
namespace PR6107 {
struct S1 { };
struct S2 {
struct S1;
};
struct S2::S1 { };
S1 s1;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/class
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/class/class.nest/p1.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
class Outer {
int x;
static int sx;
int f();
// C++11 does relax this rule (see 5.1.1.10) in the first case, but we need to enforce it in C++03 mode.
class Inner {
static char a[sizeof(x)]; // expected-error {{invalid use of non-static data member 'x'}}
static char b[sizeof(sx)]; // okay
static char c[sizeof(f)]; // expected-error {{call to non-static member function without an object argument}}
};
};
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/basic/basic.lookup
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6-0x.cpp
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
// expected-no-diagnostics
struct C {
typedef int I;
};
typedef int I1, I2;
extern int* p;
extern int* q;
void f() {
p->C::I::~I();
q->I1::~I2();
}
struct A {
~A();
};
typedef A AB;
int main() {
AB *p;
p->AB::~AB();
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/basic/basic.lookup
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/p6.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
struct C {
typedef int I;
};
typedef int I1, I2;
extern int* p;
extern int* q;
void f() {
p->C::I::~I();
q->I1::~I2();
}
struct A {
~A();
};
typedef A AB;
int main() {
AB *p;
p->AB::~AB();
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/basic/basic.lookup/basic.lookup.qual
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p4.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
namespace A {
int a;
}
namespace C {
int c;
}
namespace B {
using namespace C;
int b;
}
namespace C {
using namespace B;
using namespace A;
}
void test() {
C::a++;
C::b++;
C::c++;
}
|
0 |
repos/DirectXShaderCompiler/tools/clang/test/CXX/basic/basic.lookup/basic.lookup.qual
|
repos/DirectXShaderCompiler/tools/clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p3.cpp
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
// This is basically paraphrased from the standard.
namespace Root {
int i = 0;
void f();
}
namespace A {
using namespace Root;
}
namespace B {
using namespace Root;
}
namespace AB {
using namespace A;
using namespace B;
}
void test() {
if (AB::i)
AB::f();
}
namespace C {
using Root::i;
using Root::f;
}
namespace AC {
using namespace A;
using namespace C;
}
void test2() {
if (AC::i)
AC::f();
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.