brintos

brintos / llvm-project-archived public Read only

0
0
Text · 602 B · dd13901 Raw
28 lines · cpp
1// RUN: %clang_cc1 -std=c++2a -x c++ %s -verify2 3namespace use_after_instantiation {4  template<int &R> struct A { static constexpr int &value = R; };5 6  template<typename = void> auto S() {7    static int s;8    return A<s>{};9  }10 11  auto &s = decltype(S())::value;12 13  // This is ill-formed, but it should not crash.14  // FIXME: Right now, it does crash.15  // expected-no-diagnostics16#if 017  template<typename = void> auto T() {18    static int s;19    struct A {20      static constexpr int &value = s; // expected-error {{static}}21    };22    return A{};23  }24 25  auto &t = decltype(T())::value;26#endif27}28