Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88790ee

Browse files
a-tarasyukc-rhodes
authored andcommitted
[Clang] add long double test to cover constant expression evaluation (#175645)
Fixes #174113 (comment) --- This patch adds a test to cover the `long double` case during constant expression evaluation
1 parent 3d772bf commit 88790ee

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

clang/test/Sema/constexpr.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,17 @@ bool issue155507(v2int16_t a, v2int16_t b) {
402402
constexpr bool b2 = (bool)nullptr;
403403
_Static_assert(!b2);
404404

405-
double ghissue173847(double a) {
405+
double gh173847_double(double a) {
406406
double result = 3.0 / (a + 4.5 - 2.1 * 0.7);
407407
return result;
408408
}
409-
void ghissue173847_test() {
410-
constexpr float f_const = ghissue173847(2.0); // expected-error {{constexpr variable 'f_const' must be initialized by a constant expression}}
409+
410+
long double gh173847_long_double(long double a) {
411+
long double result = 3.0L / (a + 4.5L - 2.1L * 0.7L);
412+
return result;
413+
}
414+
415+
void gh173847_test() {
416+
constexpr double d_const = gh173847_double(2.0); // expected-error {{constexpr variable 'd_const' must be initialized by a constant expression}}
417+
constexpr long double ld_const = gh173847_long_double(2.0L); // expected-error {{constexpr variable 'ld_const' must be initialized by a constant expression}}
411418
}

0 commit comments

Comments
 (0)