class Cls { public:
Cls(int x);
Cls(const Cls &);
Cls(Cls &&);
~Cls();
};
class SubCls1 : public Cls {};
typedef Cls ClsAlias;
class SubCls2 : public ClsAlias {};
Cls::Cls(int x) {}
Cls::~Cls() {}
template <typename TemplArg>
class TemplCls {
public:
TemplCls(int x);
};
template<>
class TemplCls<double> {
};
TemplCls<int> gtv(0);
template<class T>
class Wrapper {};
template<class T, class P>
class Wrapper<T(P)> {};
void test1(Wrapper<void(int)> f);
void test1(Wrapper<void(int)> f) {}
template <typename T>
class BT {
struct KLR {
int idx;
};
KLR foo() {
return { .idx = 0 }; }
};
typedef unsigned long size_t;
void* operator new(size_t sz);
template<typename T> static const T tmplVar = T(0);
template<> static const int tmplVar<int> = 0;
int gvi = tmplVar<int>;
int gvf = tmplVar<float>;
template<typename A, typename B>
class PartialSpecilizationClass { };
template<typename B>
class PartialSpecilizationClass<int, B *> { };
template<>
class PartialSpecilizationClass<int, int> { };
template<typename T, typename S>
class PseudoOverridesInSpecializations {
void function() { }
void function(int) { }
static void staticFunction() { }
int field;
static int variable;
typedef T TypeDef;
using TypeAlias = T;
enum anEnum { };
struct Struct { };
union Union { };
using TypealiasOrRecord = void;
template<typename U> struct InnerTemplate { };
template<typename U> struct InnerTemplate <U*> { };
template<typename U>
class InnerClass { };
};
template<>
class PseudoOverridesInSpecializations<double, int> {
void function() { }
void staticFunction() { }
int notOverridingField = 0;
int checLabelBreak = 0;
int field = 0;
static double variable;
typedef double TypeDef;
using TypeAlias = int;
enum anEnum { };
class Struct { };
union Union { };
struct TypealiasOrRecord { };
template<typename U> struct InnerTemplate { };
template<typename U> struct InnerTemplate <U*> { };
template<typename U>
class InnerClass;
};
template<typename U>
class PseudoOverridesInSpecializations<double, int>::InnerClass {
};
template<typename S>
class PseudoOverridesInSpecializations<float, S> {
typedef float TypealiasOrRecord;
};
template<typename T, typename U>
class ConflictingPseudoOverridesInSpecialization {
void foo(T x);
void foo(U x);
};
template<typename T>
class ConflictingPseudoOverridesInSpecialization<int, T> {
void foo(T x);
};
template<typename T, typename U, int x>
void functionSpecialization();
template<typename T, typename U, int x>
void functionSpecialization() { }
template<>
void functionSpecialization<int, int, 0>();
template<>
void functionSpecialization<int, int, 0>() { }
struct ContainsSpecializedMemberFunction {
template<typename T>
void memberSpecialization();
};
template<typename T>
void ContainsSpecializedMemberFunction::memberSpecialization() {
}
template<>
void ContainsSpecializedMemberFunction::memberSpecialization<int>() {
}
template<typename T>
class SpecializationDecl;
template<typename T>
class SpecializationDecl { };
template<>
class SpecializationDecl<int>;
template<>
class SpecializationDecl<int> { };
template<typename T>
class PartialSpecilizationClass<Cls, T>;
template<>
class PartialSpecilizationClass<Cls, Cls> : Cls { };
template<typename T, int x>
void functionSp() { }
struct Record {
constexpr static int C = 2;
};
template<>
void functionSp<SpecializationDecl<Cls>, Record::C>() {
}
template<typename T, int x>
class ClassWithCorrectSpecialization { };
template<>
class ClassWithCorrectSpecialization<SpecializationDecl<Cls>, Record::C> { };
namespace ns {
namespace inner {
void func();
}
namespace innerAlias = inner;
}
namespace namespaceAlias = ::ns::innerAlias;
void ::ns::inner::func() {
ns::innerAlias::func();
}
void innerUsingNamespace() {
using namespace ns;
{
using namespace ns::innerAlias;
}
}
void indexDefaultValueInDefn(Cls cls = Cls(gvi), Record param = Record()) {
}
template<template <typename> class T>
struct IndexDefaultValue {
IndexDefaultValue(int k = Record::C) {
}
};
struct DeletedMethods {
DeletedMethods(const DeletedMethods &) = delete;
};
namespace ns2 {
template<typename T> struct ACollectionDecl { };
}
template<typename T = Cls,
int x = Record::C,
template <typename> class Collection = ns2::ACollectionDecl>
struct TemplateDefaultValues { };
template<typename T = Record,
int x = sizeof(Cls)>
void functionTemplateDefaultValues() { }
namespace ensureDefaultTemplateParamsAreRecordedOnce {
template<typename T = Cls>
void functionDecl();
template<typename T>
void functionDecl() { }
template<typename T = Cls>
class TagDecl;
template<typename T>
class TagDecl;
template<typename T>
class TagDecl { };
template<typename T = Cls>
using TypeAlias = TagDecl<T>;
template<typename T = Cls>
extern T varDecl;
template<typename T>
T varDecl = T();
}
struct StaticAssertRef {
static constexpr bool constVar = true;
};
static_assert(StaticAssertRef::constVar, "index static asserts");
void staticAssertInFn() {
static_assert(StaticAssertRef::constVar, "index static asserts");
}
namespace cpp17structuredBinding {
struct Cpp17StructuredBinding {
int x, y;
Cpp17StructuredBinding(int x, int y): x(x), y(y) { }
};
auto [structuredBinding1, structuredBinding2] = Cpp17StructuredBinding(Record::C, 0);
void localStructuredBindingAndRef() {
int ref = structuredBinding1;
auto [localBinding1, localBinding2] = Cpp17StructuredBinding(ref, structuredBinding2);
}
}
template<typename T>
struct Guided { T t; };
Guided(double) -> Guided<float>;
auto guided = Guided{1.0};
namespace rd33122110 {
struct Outer {
template<typename T>
struct Nested { };
};
}
template<>
struct rd33122110::Outer::Nested<int>;
namespace index_offsetof {
struct Struct {
int field;
};
struct Struct2 {
Struct array[4][2];
};
void foo() {
__builtin_offsetof(Struct, field);
__builtin_offsetof(Struct2, array[1][0].field);
}
#define OFFSET_OF_(X, Y) __builtin_offsetof(X, Y)
class SubclassOffsetof : public Struct {
void foo() {
OFFSET_OF_(SubclassOffsetof, field);
}
};
}
namespace clangd_issue_504 {
class A {};
template <typename> class B {};
class C : B<A> {};
}