|
1 |
| -// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both %s |
2 |
| -// RUN: %clang_cc1 -std=c++14 -fexperimental-new-constant-interpreter -verify=expected,both %s |
3 |
| -// RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter -verify=expected,both %s |
4 |
| -// RUN: %clang_cc1 -verify=ref,both %s |
5 |
| -// RUN: %clang_cc1 -std=c++14 -verify=ref,both %s |
6 |
| -// RUN: %clang_cc1 -std=c++20 -verify=ref,both %s |
| 1 | +// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -pedantic -verify=expected,both %s |
| 2 | +// RUN: %clang_cc1 -std=c++14 -fexperimental-new-constant-interpreter -pedantic -verify=expected,both %s |
| 3 | +// RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter -pedantic -verify=expected,both %s |
| 4 | +// RUN: %clang_cc1 -pedantic -verify=ref,both %s |
| 5 | +// RUN: %clang_cc1 -pedantic -std=c++14 -verify=ref,both %s |
| 6 | +// RUN: %clang_cc1 -pedantic -std=c++20 -verify=ref,both %s |
7 | 7 |
|
8 | 8 | constexpr void doNothing() {}
|
9 | 9 | constexpr int gimme5() {
|
@@ -471,7 +471,7 @@ namespace AddressOf {
|
471 | 471 | constexpr int foo() {return 1;}
|
472 | 472 | static_assert(__builtin_addressof(foo) == foo, "");
|
473 | 473 |
|
474 |
| - constexpr _Complex float F = {3, 4}; |
| 474 | + constexpr _Complex float F = {3, 4}; // both-warning {{'_Complex' is a C99 extension}} |
475 | 475 | static_assert(__builtin_addressof(F) == &F, "");
|
476 | 476 |
|
477 | 477 | void testAddressof(int x) {
|
@@ -633,3 +633,14 @@ namespace {
|
633 | 633 | void (&r)() = f;
|
634 | 634 | void (&cond3)() = r;
|
635 | 635 | }
|
| 636 | + |
| 637 | +namespace FunctionCast { |
| 638 | + // When folding, we allow functions to be cast to different types. Such |
| 639 | + // cast functions cannot be called, even if they're constexpr. |
| 640 | + constexpr int f() { return 1; } |
| 641 | + typedef double (*DoubleFn)(); |
| 642 | + typedef int (*IntFn)(); |
| 643 | + int a[(int)DoubleFn(f)()]; // both-error {{variable length array}} \ |
| 644 | + // both-warning {{are a Clang extension}} |
| 645 | + int b[(int)IntFn(f)()]; // ok |
| 646 | +} |
0 commit comments