blob: 9aec0c90e61dc7dc1439bbcb923f42c974d1a3c1 [file] [log] [blame]
serge-sans-pailleda6a14b2022-06-18 13:48:41 +02001// RUN: %clang_cc1 %s -fsyntax-only -verify
Timm Bädercfa30fa2024-01-15 13:48:23 +01002// RUN: %clang_cc1 %s -fexperimental-new-constant-interpreter -fsyntax-only -verify
serge-sans-pailleda6a14b2022-06-18 13:48:41 +02003
4template <typename T>
5constexpr T foo(T a); // expected-note {{declared here}}
6
7int main() {
8 int k = foo<int>(5); // Ok
9 constexpr int j = // expected-error {{constexpr variable 'j' must be initialized by a constant expression}}
10 foo<int>(5); // expected-note {{undefined function 'foo<int>' cannot be used in a constant expression}}
11}
12
13template <typename T>
14constexpr T foo(T a) {
15 return a;
16}