serge-sans-paille | da6a14b | 2022-06-18 13:48:41 +0200 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -fsyntax-only -verify |
Timm Bäder | cfa30fa | 2024-01-15 13:48:23 +0100 | [diff] [blame] | 2 | // RUN: %clang_cc1 %s -fexperimental-new-constant-interpreter -fsyntax-only -verify |
serge-sans-paille | da6a14b | 2022-06-18 13:48:41 +0200 | [diff] [blame] | 3 | |
| 4 | template <typename T> |
| 5 | constexpr T foo(T a); // expected-note {{declared here}} |
| 6 | |
| 7 | int 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 | |
| 13 | template <typename T> |
| 14 | constexpr T foo(T a) { |
| 15 | return a; |
| 16 | } |