template<bool If, typename Type>
struct enable_if {
using type= Type;
};
template<typename Type>
struct enable_if<false, Type> {};
template<typename T1, typename T2>
struct is_same {
static constexpr bool value = false;
};
template<typename T1>
struct is_same<T1, T1> {
static constexpr bool value = true;
};
constexpr const char *str() {
return "abc";
}
template<typename T, typename enable_if<!is_same<int, T>::value, int>::type = 0>
constexpr T fail_on_int(T t) {return t;}
namespace test0 {
template<typename T, T v>
struct A {
[[clang::annotate("test", fail_on_int(v))]] void t() {}
[[clang::annotate("test", (typename enable_if<!is_same<long, T>::value, int>::type)v)]] void t1() {}
};
A<int, 9> a;
A<long, 7> a1;
A<unsigned long, 6> a2;
template<typename T>
struct B {
[[clang::annotate("test", ((void)T{}, 9))]] void t() {}
};
B<int> b;
B<void> b1;
}
namespace test1 {
int g_i;
[[clang::annotate("test", "arg")]] void t3() {}
template <typename T, T V>
struct B {
static T b; static constexpr T cb = V;
template <typename T1, T1 V1>
struct foo {
static T1 f; static constexpr T1 cf = V1;
int v __attribute__((annotate("v_ann_0", str(), 90, V, g_i))) __attribute__((annotate("v_ann_1", V1)));
[[clang::annotate("qdwqwd", cf, cb)]] void t() {}
[[clang::annotate("qdwqwd", f, cb)]] void t1() {}
[[clang::annotate("jui", b, cf)]] void t2() {}
[[clang::annotate("jui", ((void)b, 0), cf)]] [[clang::annotate("jui", &b, cf, &foo::t2, str())]] void t3() {}
};
};
static B<int long, -1>::foo<unsigned, 9> gf; static B<int long, -2> gf1;
}
namespace test2 {
template<int I>
int f() {
[[clang::annotate("test", I)]] int v = 0; [[clang::annotate("test", v)]] int v2 = 0;
[[clang::annotate("test", rtyui)]] int v3 = 0;
}
void test() {}
}
namespace test3 {
void f() {
int n = 10;
int vla[n];
[[clang::annotate("vlas are awful", sizeof(vla))]] int i = 0; [[clang::annotate("_Generic selection expression should be fine", _Generic(n, int : 0, default : 1))]]
int j = 0; }
void designator();
[[clang::annotate("function designators?", designator)]] int k = 0;
void self() {
[[clang::annotate("function designators?", self)]] int k = 0;
}
}
namespace test4 {
constexpr int foldable_but_invalid() {
int *A = new int(0);
return *A;
}
[[clang::annotate("", foldable_but_invalid())]] void f1() {}
[[clang::annotate()]] void f2() {}
template <typename T> [[clang::annotate()]] void f2() {}
}