aboutsummaryrefslogtreecommitdiff
path: root/clang/test/SemaTemplate/instantiate-static-local.cpp
blob: dd139011ac6bdc9e572674291a6d6273ec421d1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// RUN: %clang_cc1 -std=c++2a -x c++ %s -verify

namespace use_after_instantiation {
  template<int &R> struct A { static constexpr int &value = R; };

  template<typename = void> auto S() {
    static int s;
    return A<s>{};
  }

  auto &s = decltype(S())::value;

  // This is ill-formed, but it should not crash.
  // FIXME: Right now, it does crash.
  // expected-no-diagnostics
#if 0
  template<typename = void> auto T() {
    static int s;
    struct A {
      static constexpr int &value = s; // expected-error {{static}}
    };
    return A{};
  }

  auto &t = decltype(T())::value;
#endif
}