brintos

brintos / llvm-project-archived public Read only

0
0
Text · 841 B · 91fe782 Raw
30 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s                                         | FileCheck %s2// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s -fexperimental-new-constant-interpreter | FileCheck %s3 4template<typename T>5struct Wrapper {6  T *Val;7 8  template<typename _Up>9  constexpr Wrapper(_Up&& __u) {10    T& __f = static_cast<_Up&&>(__u);11    Val = &__f;12  }13  constexpr T& get() const { return *Val; }14};15 16void f(){}17int main() {18  auto W = Wrapper<decltype(f)>(f);19 20  if (&W.get() != &f)21    __builtin_abort();22}23 24/// We used to convert do the pointer->fnptr conversion25/// by doing an integer conversion in between, which caused the26/// %0 line to be:27/// store ptr inttoptr (i64 138574454870464 to ptr), ptr %__f, align 828// CHECK: @_ZN7WrapperIFvvEEC2IRS0_EEOT_29// CHECK: %0 = load ptr, ptr %__u.addr30