xref: /aosp_15_r20/external/clang/test/CodeGenCXX/enable_if.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-linux-gnu| FileCheck %s
2*67e74705SXin Li 
3*67e74705SXin Li // Test address-of overloading logic
4*67e74705SXin Li int test5(int);
5*67e74705SXin Li template <typename T>
6*67e74705SXin Li T test5(T) __attribute__((enable_if(1, "better than non-template")));
7*67e74705SXin Li 
8*67e74705SXin Li // CHECK: @_Z5test5IiEUa9enable_ifIXLi1EEET_S0_
9*67e74705SXin Li int (*Ptr)(int) = &test5;
10*67e74705SXin Li 
11*67e74705SXin Li // Test itanium mangling for attribute enable_if
12*67e74705SXin Li 
13*67e74705SXin Li // CHECK: _Z5test1Ua9enable_ifIXeqfL0p_Li1EEEi
test1(int i)14*67e74705SXin Li void test1(int i) __attribute__((enable_if(i == 1, ""))) {}
15*67e74705SXin Li 
16*67e74705SXin Li void ext();
17*67e74705SXin Li // CHECK: _Z5test2Ua9enable_ifIXneadL_Z3extvELi0EEEi
test2(int i)18*67e74705SXin Li void test2(int i) __attribute__((enable_if(&ext != 0, ""))) {}
19*67e74705SXin Li 
20*67e74705SXin Li // CHECK: _Z5test3Ua9enable_ifIXeqfL0p_Li1EEXeqfL0p0_Li2EEEii
test3(int i,int j)21*67e74705SXin Li void test3(int i, int j) __attribute__((enable_if(i == 1, ""), enable_if(j == 2, ""))) {}
22*67e74705SXin Li 
23*67e74705SXin Li // CHECK: _ZN5test4IdE1fEUa9enable_ifIXeqfL0p_Li1EEXeqfL0p0_Li2EEEi
24*67e74705SXin Li template <typename T>
25*67e74705SXin Li class test4 {
26*67e74705SXin Li   virtual void f(int i, int j) __attribute__((enable_if(i == 1, ""))) __attribute__((enable_if(j == 2, "")));
27*67e74705SXin Li };
28*67e74705SXin Li 
29*67e74705SXin Li template class test4<double>;
30