llvm-project/clang/test/SemaOpenMP/openmp-begin-declare-variant_template.cpp
Matheus Izvekov 7731156f30
[clang] OpenMP: fix variant template mismatch crash (#164511)
This ammends the fix commited in https://reviews.llvm.org/D109770 /
6cf6fa6ef1c28

Comparing the number of template parameter lists with the number of
template parameters is obviously wrong.

Even then, the number of parameters being the same doesn't mean the
templates are compatible.

This change compares if the template parameters are actually equivalent.

This fixes the crash, but I am not sure what is the design and intention
here, this openmp template support looks too fragile.

The added test case still doesn't work, but at least we don't crash now.
2025-10-23 13:37:59 -03:00

13 lines
459 B
C++

// RUN: %clang_cc1 -triple x86_64 -fopenmp -verify %s
// FIXME: Is this supposed to work?
#pragma omp begin declare variant match(implementation={extension(allow_templates)})
template <class T> void f(T) {}
// expected-note@-1 {{explicit instantiation refers here}}
#pragma end
template <int> struct A {};
template <bool B> A<B> f() = delete;
template void f<float>(float);
// expected-error@-1 {{explicit instantiation of undefined function template 'f'}}