Skip to content

Commit 853059a

Browse files
committed
[libc++] Addresses LWG3782.
3782. Should <math.h> declare ::lerp? Libc++ doesn't declare ::lerp, adds tests to validate the requirement. Reviewed By: #libc, philnik Differential Revision: https://reviews.llvm.org/D142817
1 parent 27c3c6c commit 853059a

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

libcxx/docs/Status/Cxx2bIssues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
"`3775 <https://wg21.link/LWG3775>`__","Broken dependencies in the ``Cpp17Allocator`` requirements", "November 2022","","",""
228228
"`3778 <https://wg21.link/LWG3778>`__","``vector<bool>`` missing exception specifications", "November 2022","","",""
229229
"`3781 <https://wg21.link/LWG3781>`__","The exposition-only alias templates ``cont-key-type`` and ``cont-mapped-type`` should be removed", "November 2022","|Nothing to do|","",""
230-
"`3782 <https://wg21.link/LWG3782>`__","Should ``<math.h>`` declare ``::lerp``?", "November 2022","","",""
230+
"`3782 <https://wg21.link/LWG3782>`__","Should ``<math.h>`` declare ``::lerp``?", "November 2022","|Complete|","17.0",""
231231
"`3784 <https://wg21.link/LWG3784>`__","std.compat should not provide ``::byte`` and its friends", "November 2022","","",""
232232
"`3785 <https://wg21.link/LWG3785>`__","``ranges::to`` is over-constrained on the destination type being a range", "November 2022","","","|ranges|"
233233
"`3788 <https://wg21.link/LWG3788>`__","``jthread::operator=(jthread&&)`` postconditions are unimplementable under self-assignment", "November 2022","","",""
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// When built with modules, this test gives diagnostics like
10+
// declaration of 'lerp' must be imported from module 'std.compat.cmath'
11+
// before it is required
12+
// therefore disable the test in this configuration.
13+
// UNSUPPORTED: modules-build
14+
15+
// <math.h>
16+
17+
// [support.c.headers.other]/1
18+
// ... except for the functions described in [sf.cmath], the
19+
// std::lerp function overloads ([c.math.lerp]) ...
20+
21+
#include <math.h>
22+
23+
void f() {
24+
{
25+
float f;
26+
::lerp(f, f, f); // expected-error {{no member named 'lerp' in the global namespace}}
27+
std::lerp(f, f, f); // expected-error {{no member named 'lerp' in namespace 'std'}}
28+
}
29+
{
30+
double d;
31+
::lerp(d, d, d); // expected-error {{no member named 'lerp' in the global namespace}}
32+
std::lerp(d, d, d); // expected-error {{no member named 'lerp' in namespace 'std'}}
33+
}
34+
{
35+
long double l;
36+
::lerp(l, l, l); // expected-error {{no member named 'lerp' in the global namespace}}
37+
std::lerp(l, l, l); // expected-error {{no member named 'lerp' in namespace 'std'}}
38+
}
39+
}

0 commit comments

Comments
 (0)