[PATCH] Instantiate static constexpr member function of a local struct in a function template earlier.
Richard Smith
richard at metafoo.co.uk
Mon Apr 27 15:17:08 PDT 2015
On Fri, Apr 24, 2015 at 1:24 PM, Michael Park <mcypark at gmail.com> wrote:
> This patch instantiates the pending local instantiations earlier in order
> to enable to following code to compile:
>
> template <typename T>
> void F() {
> struct Num {
> static constexpr int Get() { return 42; }
> };
> constexpr int n = Num::Get();
> }
>
> int main() {
> F<int>();
> }
>
> This addresses PR20625.
>
Hmm. This approach still rejects this:
template<typename T> void f() {
struct X {
static constexpr int get() { return 42; }
int arr[get()];
};
}
template void f<int>();
I'm OK with that; we reject the corresponding non-template case, but accept
the corresponding non-local class template case.
LGTM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150427/66cb0638/attachment.html>
More information about the cfe-commits
mailing list