|
| 1 | +// This test is intended to validate whether decimal floating-point (DFP) |
| 2 | +// extensions are enabled based on language standard and to ensure a proper |
| 3 | +// diagnostic is issued for any use of DFP features otherwise. |
| 4 | + |
| 5 | +// RUN: %clang -target x86_64-unknown-linux-gnu -std=c17 -fsyntax-only -Xclang -verify=dfp-off,c-dfp-off %s |
| 6 | +// RUN: %clang -target x86_64-unknown-linux-gnu -std=c17 -fsyntax-only -fexperimental-decimal-floating-point -Xclang -verify %s |
| 7 | +// FIXME: Remove -fexperimental-decimal-floating-point once -std=c23 implies DFP enablement. |
| 8 | +// RUN: %clang -target x86_64-unknown-linux-gnu -std=c23 -fsyntax-only -fexperimental-decimal-floating-point -Xclang -verify %s |
| 9 | +// RUN: %clang -target x86_64-unknown-linux-gnu -std=c23 -fsyntax-only -fno-experimental-decimal-floating-point -Xclang -verify=dfp-off,c-dfp-off %s |
| 10 | +// RUN: %clang -target x86_64-unknown-linux-gnu -x c++ -std=c++23 -fsyntax-only -Xclang -verify=cxx,dfp-off %s |
| 11 | +// RUN: %clang -target x86_64-unknown-linux-gnu -x c++ -std=c++23 -fsyntax-only -fexperimental-decimal-floating-point -Xclang -verify=cxx %s |
| 12 | +// FIXME: Remove -fexperimental-decimal-floating-point once -std=c++2c (or later) implies DFP enablement. |
| 13 | +// RUN: %clang -target x86_64-unknown-linux-gnu -x c++ -std=c++2c -fsyntax-only -fexperimental-decimal-floating-point -Xclang -verify=cxx %s |
| 14 | +// RUN: %clang -target x86_64-unknown-linux-gnu -x c++ -std=c++2c -fsyntax-only -fno-experimental-decimal-floating-point -Xclang -verify=cxx,dfp-off %s |
| 15 | + |
| 16 | +// expected-no-diagnostics |
| 17 | + |
| 18 | +#if defined(__cplusplus) |
| 19 | + #if defined(__STDC_IEC_60559_DFP__) |
| 20 | + #error __STDC_IEC_60559_DFP__ should never be defined for C++ |
| 21 | + #endif |
| 22 | +#else |
| 23 | + #if !defined(__STDC_IEC_60559_DFP__) |
| 24 | + // c-dfp-off-error@+1 {{__STDC_IEC_60559_DFP__ should be defined}} |
| 25 | + #error __STDC_IEC_60559_DFP__ should be defined for C when DFP support is enabled |
| 26 | + #elif __STDC_IEC_60559_DFP__ != 197001L |
| 27 | + #error __STDC_IEC_60559_DFP__ has the wrong value |
| 28 | + #endif |
| 29 | +#endif |
| 30 | + |
| 31 | +_Decimal32 d32; // cxx-error {{unknown type name '_Decimal32'}} \ |
| 32 | + // c-dfp-off-error {{decimal floating-point extensions are not enabled}} |
| 33 | +_Decimal64 d64; // cxx-error {{unknown type name '_Decimal64'}} \ |
| 34 | + // c-dfp-off-error {{decimal floating-point extensions are not enabled}} |
| 35 | +_Decimal128 d128; // cxx-error {{unknown type name '_Decimal128'}} \ |
| 36 | + // c-dfp-off-error {{decimal floating-point extensions are not enabled}} |
0 commit comments