aboutsummaryrefslogtreecommitdiff
path: root/clang/test/SemaCXX/constexpr-late-instantiation.cpp
blob: 9aec0c90e61dc7dc1439bbcb923f42c974d1a3c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// RUN: %clang_cc1 %s -fsyntax-only -verify
// RUN: %clang_cc1 %s -fexperimental-new-constant-interpreter -fsyntax-only -verify

template <typename T>
constexpr T foo(T a);   // expected-note {{declared here}}

int main() {
  int k = foo<int>(5);  // Ok
  constexpr int j =     // expected-error {{constexpr variable 'j' must be initialized by a constant expression}}
          foo<int>(5);  // expected-note {{undefined function 'foo<int>' cannot be used in a constant expression}}
}

template <typename T>
constexpr T foo(T a) {
  return a;
}