[clang] NFC: new tests and some cleanups on existing ones (#142293)
This offloads some test changes from another PR in order to facilitate review. - Adds some new tests. - Cleans stray spaces and newlines on existing tests. - Regenerates some AST json dumps, as the generator now includes offsets.
This commit is contained in:
parent
2c855e629c
commit
fbb22ce1aa
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -168,3 +168,29 @@ namespace abstract {
|
||||
// CHECK-NOT: @_ZN8abstract1BD0Ev(
|
||||
B::~B() {}
|
||||
}
|
||||
|
||||
namespace redecl {
|
||||
struct A {
|
||||
A();
|
||||
};
|
||||
class A;
|
||||
|
||||
// CHECK-LABEL: define{{.*}} void @_ZN6redecl1AC2Ev(
|
||||
// CHECK: define{{.*}} void @_ZN6redecl1AC1Ev(
|
||||
// CHECK: call {{.*}} @_ZN6redecl1AC2Ev(
|
||||
A::A() {}
|
||||
}
|
||||
|
||||
namespace fwdecl {
|
||||
struct A;
|
||||
struct A {
|
||||
int v;
|
||||
};
|
||||
struct B : A {
|
||||
B() = default;
|
||||
B(int);
|
||||
};
|
||||
struct C : B {};
|
||||
|
||||
void f() { C{}; }
|
||||
}
|
||||
|
@ -45,6 +45,8 @@
|
||||
// RUN: FileCheck --check-prefix=CHECK-44 %s < %t
|
||||
// RUN: FileCheck --check-prefix=CHECK-45 %s < %t
|
||||
// RUN: FileCheck --check-prefix=CHECK-46 %s < %t
|
||||
// RUN: FileCheck --check-prefix=CHECK-47 %s < %t
|
||||
// RUN: FileCheck --check-prefix=CHECK-48 %s < %t
|
||||
|
||||
// For now, just verify this doesn't crash.
|
||||
namespace test0 {
|
||||
@ -1925,3 +1927,80 @@ namespace Test40 {
|
||||
|
||||
D d;
|
||||
}
|
||||
|
||||
namespace Test41 {
|
||||
struct A {
|
||||
virtual ~A();
|
||||
};
|
||||
struct B;
|
||||
struct B : A {};
|
||||
// CHECK-47-LABEL: Vtable for 'Test41::C' (4 entries).
|
||||
// CHECK-47-NEXT: 0 | offset_to_top (0)
|
||||
// CHECK-47-NEXT: 1 | Test41::C RTTI
|
||||
// CHECK-47-NEXT: -- (Test41::A, 0) vtable address --
|
||||
// CHECK-47-NEXT: -- (Test41::B, 0) vtable address --
|
||||
// CHECK-47-NEXT: -- (Test41::C, 0) vtable address --
|
||||
// CHECK-47-NEXT: 2 | Test41::C::~C() [complete]
|
||||
// CHECK-47-NEXT: 3 | Test41::C::~C() [deleting]
|
||||
|
||||
// CHECK-47-LABEL: VTable indices for 'Test41::C' (2 entries).
|
||||
// CHECK-47-NEXT: 0 | Test41::C::~C() [complete]
|
||||
// CHECK-47-NEXT: 1 | Test41::C::~C() [deleting]
|
||||
struct C : B {};
|
||||
C c;
|
||||
}
|
||||
|
||||
namespace Test42 {
|
||||
// CHECK-48-LABEL: Vtable for 'Test42::C' (3 entries).
|
||||
// CHECK-48-NEXT: 0 | offset_to_top (0)
|
||||
// CHECK-48-NEXT: 1 | Test42::C RTTI
|
||||
// CHECK-48-NEXT: -- (Test42::A, 0) vtable address --
|
||||
// CHECK-48-NEXT: -- (Test42::B, 0) vtable address --
|
||||
// CHECK-48-NEXT: -- (Test42::C, 0) vtable address --
|
||||
// CHECK-48-NEXT: 2 | void Test42::A::f()
|
||||
|
||||
// CHECK-48-LABEL: Vtable for 'Test42::B' (3 entries).
|
||||
// CHECK-48-NEXT: 0 | offset_to_top (0)
|
||||
// CHECK-48-NEXT: 1 | Test42::B RTTI
|
||||
// CHECK-48-NEXT: -- (Test42::A, 0) vtable address --
|
||||
// CHECK-48-NEXT: -- (Test42::B, 0) vtable address --
|
||||
// CHECK-48-NEXT: 2 | void Test42::A::f()
|
||||
|
||||
// CHECK-48-LABEL: Vtable for 'Test42::A' (3 entries).
|
||||
// CHECK-48-NEXT: 0 | offset_to_top (0)
|
||||
// CHECK-48-NEXT: 1 | Test42::A RTTI
|
||||
// CHECK-48-NEXT: -- (Test42::A, 0) vtable address --
|
||||
// CHECK-48-NEXT: 2 | void Test42::A::f()
|
||||
// CHECK-48-LABEL: VTable indices for 'Test42::A' (1 entries).
|
||||
// CHECK-48-NEXT: 0 | void Test42::A::f()
|
||||
struct A {
|
||||
virtual void f();
|
||||
};
|
||||
struct B;
|
||||
struct B : A {};
|
||||
struct C : B {};
|
||||
void test() { C c; }
|
||||
}
|
||||
|
||||
namespace Test43 {
|
||||
struct A {
|
||||
virtual ~A();
|
||||
};
|
||||
template <class T> struct B : T {};
|
||||
struct C;
|
||||
struct C : A {};
|
||||
// CHECK-49-LABEL: Vtable for 'Test43::D' (4 entries).
|
||||
// CHECK-49-NEXT: 0 | offset_to_top (0)
|
||||
// CHECK-49-NEXT: 1 | Test43::D RTTI
|
||||
// CHECK-49-NEXT: -- (Test43::A, 0) vtable address --
|
||||
// CHECK-49-NEXT: -- (Test43::B, 0) vtable address --
|
||||
// CHECK-49-NEXT: -- (Test43::C, 0) vtable address --
|
||||
// CHECK-49-NEXT: -- (Test43::D, 0) vtable address --
|
||||
// CHECK-49-NEXT: 2 | Test43::D::~D() [complete]
|
||||
// CHECK-49-NEXT: 3 | Test43::D::~D() [deleting]
|
||||
// CHECK-49-LABEL: VTable indices for 'D' (2 entries).
|
||||
// CHECK-49-NEXT: 0 | Test43::D::~D() [complete]
|
||||
// CHECK-49-NEXT: 1 | Test43::D::~D() [deleting]
|
||||
struct D : B<C> {};
|
||||
D d;
|
||||
}
|
||||
|
11
clang/test/Parser/cxx-nested-name.cpp
Normal file
11
clang/test/Parser/cxx-nested-name.cpp
Normal file
@ -0,0 +1,11 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
// expected-no-diagnostics
|
||||
|
||||
namespace binary_operator {
|
||||
namespace N {
|
||||
template <class> struct A {
|
||||
static const int y = 0;
|
||||
};
|
||||
} // namespace N
|
||||
void f(int x) { (void)(x < N::A<int>::y); }
|
||||
} // namespace binary_operator
|
@ -18,3 +18,14 @@ namespace PR40329 {
|
||||
int k1 = B::e ->* B();
|
||||
int k2 = B() ->* B::e;
|
||||
}
|
||||
|
||||
namespace ForwardDecl {
|
||||
struct A {
|
||||
friend class B;
|
||||
};
|
||||
struct B {
|
||||
enum E { X };
|
||||
friend E operator|(E, E);
|
||||
void g() { operator|(X, X); }
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx98 -std=c++98 %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s
|
||||
|
||||
@ -206,3 +206,18 @@ A GetA() {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace ForwardDeclaredMember {
|
||||
struct A;
|
||||
struct A {
|
||||
int x = 0;
|
||||
// cxx98-warning@-1 {{default member initializer for non-static data member is a C++11 extension}}
|
||||
// cxx98-note@-2 {{because field 'x' has an initializer}}
|
||||
};
|
||||
struct B {
|
||||
struct {
|
||||
A y;
|
||||
// cxx98-error@-1 {{anonymous struct member 'y' has a non-trivial default constructor}}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -173,3 +173,20 @@ using alias_template = class_template<Extents...>;
|
||||
alias_template var2{converible_to_one{}, 2};
|
||||
|
||||
}
|
||||
|
||||
namespace GH136624 {
|
||||
// expected-note@+1 2{{no known conversion}}
|
||||
template<typename U> struct A {
|
||||
U t;
|
||||
};
|
||||
|
||||
template<typename V> A(V) -> A<V>;
|
||||
|
||||
namespace foo {
|
||||
template<class Y> using Alias = A<Y>;
|
||||
}
|
||||
|
||||
// FIXME: This diagnostic prints incorrect qualification for `A<int>`.
|
||||
foo::Alias t = 0;
|
||||
// expected-error@-1 {{no viable conversion from 'int' to 'foo::A<int>' (aka 'A<int>')}}
|
||||
} // namespace GH136624
|
||||
|
@ -486,3 +486,11 @@ struct x; // expected-note {{template is declared here}}
|
||||
template <typename T>
|
||||
int issue55962 = x::a; // expected-error {{use of class template 'x' requires template arguments}} \
|
||||
// expected-warning {{variable templates are a C++14 extension}}
|
||||
|
||||
namespace ForwardDeclared {
|
||||
typedef class A B;
|
||||
struct A {
|
||||
enum C {};
|
||||
void F(B::C);
|
||||
};
|
||||
}
|
||||
|
@ -414,6 +414,9 @@ struct PotentiallyFinal<T*> final { };
|
||||
template<>
|
||||
struct PotentiallyFinal<int> final { };
|
||||
|
||||
struct FwdDeclFinal;
|
||||
using FwdDeclFinalAlias = FwdDeclFinal;
|
||||
struct FwdDeclFinal final {};
|
||||
|
||||
|
||||
|
||||
@ -423,6 +426,8 @@ void is_final()
|
||||
static_assert(__is_final(FinalClass));
|
||||
static_assert(__is_final(PotentiallyFinal<float*>));
|
||||
static_assert(__is_final(PotentiallyFinal<int>));
|
||||
static_assert(__is_final(FwdDeclFinal));
|
||||
static_assert(__is_final(FwdDeclFinalAlias));
|
||||
|
||||
static_assert(!__is_final(int));
|
||||
static_assert(!__is_final(Union));
|
||||
|
@ -1,9 +0,0 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
// expected-no-diagnostics
|
||||
|
||||
namespace A {
|
||||
struct B { };
|
||||
void operator+(B,B);
|
||||
}
|
||||
|
||||
using A::operator+;
|
25
clang/test/SemaCXX/using-decl.cpp
Normal file
25
clang/test/SemaCXX/using-decl.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
namespace PR4441 {
|
||||
namespace A {
|
||||
struct B { };
|
||||
void operator+(B,B);
|
||||
}
|
||||
|
||||
using A::operator+;
|
||||
} // namespace PR4441
|
||||
|
||||
namespace qualified_name {
|
||||
namespace XXX {
|
||||
struct A {
|
||||
using type = int;
|
||||
};
|
||||
}
|
||||
|
||||
namespace YYY {
|
||||
using XXX::A;
|
||||
}
|
||||
|
||||
YYY::A::type x = nullptr;
|
||||
// expected-error@-1 {{variable of type 'YYY::A::type'}}
|
||||
} // namespace qualifed_name
|
@ -331,3 +331,13 @@ namespace PR8168 {
|
||||
static void foo() {} // expected-error{{'static' member function 'foo' overrides a virtual function}}
|
||||
};
|
||||
}
|
||||
|
||||
namespace ForwardDeclared {
|
||||
class A;
|
||||
struct B {
|
||||
virtual B *f();
|
||||
};
|
||||
struct A : B {
|
||||
A *f();
|
||||
};
|
||||
}
|
||||
|
@ -75,6 +75,8 @@ void m() {
|
||||
while (true) {}
|
||||
}
|
||||
|
||||
void n() { ::n(); } // expected-warning{{call itself}}
|
||||
|
||||
class S {
|
||||
static void a();
|
||||
void b();
|
||||
|
@ -229,3 +229,14 @@ namespace DefaultArgVsPartialSpec {
|
||||
> struct S;
|
||||
template<typename T> struct S<T> {}; // expected-error {{non-type template argument specializes a template parameter with dependent type 'T'}}
|
||||
}
|
||||
|
||||
namespace LateDefined {
|
||||
template <class> struct A;
|
||||
struct B {
|
||||
typedef A<B> X;
|
||||
};
|
||||
template <> struct A<B> {
|
||||
void f();
|
||||
};
|
||||
void A<B>::f() {}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fcxx-exceptions -Wno-dynamic-exception-spec %std_cxx11- %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fcxx-exceptions -Wno-dynamic-exception-spec -pedantic %std_cxx11- %s
|
||||
|
||||
template void *; // expected-error{{expected unqualified-id}}
|
||||
|
||||
@ -185,3 +185,12 @@ template<typename T> struct LambdaInDefaultMemberInitInExplicitInstantiation {
|
||||
template struct LambdaInDefaultMemberInitInExplicitInstantiation<int>;
|
||||
LambdaInDefaultMemberInitInExplicitInstantiation<float> x;
|
||||
#endif
|
||||
|
||||
namespace Qualified {
|
||||
template <class> struct C {
|
||||
struct D {
|
||||
void f();
|
||||
};
|
||||
};
|
||||
extern template void C<int>::D::f();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user