[X86] Move getGFNICtrlMask before CTLZ/CTTZ lowering. NFC.
[llvm-project.git] / clang / test / SemaCXX / consteval-operators.cpp
blobaddb4d69e53aa487dd0f406903ef73979deeffea
1 // RUN: %clang_cc1 -std=c++2a -emit-llvm-only -Wno-unused-value %s -verify
3 // expected-no-diagnostics
5 struct A {
6 consteval A operator+() { return {}; }
7 };
8 consteval A operator~(A) { return {}; }
9 consteval A operator+(A, A) { return {}; }
11 template <class> void f() {
12 A a;
13 A b = ~a;
14 A c = a + a;
15 A d = +a;
17 template void f<int>();
19 template <class T> void foo() {
20 T a;
21 T b = ~a;
22 T c = a + a;
23 T d = +a;
26 template void foo<A>();
28 template <typename DataT> struct B { DataT D; };
30 template <typename DataT>
31 consteval B<DataT> operator+(B<DataT> lhs, B<DataT> rhs) {
32 return B<DataT>{lhs.D + rhs.D};
35 template <class T> consteval T template_add(T a, T b) { return a + b; }
37 consteval B<int> non_template_add(B<int> a, B<int> b) { return a + b; }
39 void bar() {
40 constexpr B<int> a{};
41 constexpr B<int> b{};
42 auto constexpr c = a + b;
45 static_assert((template_add(B<int>{7}, B<int>{3})).D == 10);
46 static_assert((non_template_add(B<int>{7}, B<int>{3})).D == 10);