Files
TheRock/compiler/amd-llvm/clang/test/CXX/temp/temp.pre/p6.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

95 lines
4.1 KiB
C++

// RUN: %clang_cc1 -std=c++20 -verify %s
// RUN: not %clang_cc1 -std=c++20 -fsyntax-only -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines=1 %s 2>&1 | FileCheck %s -strict-whitespace
namespace GH46386 {
extern "C" { // expected-note {{extern "C" language linkage specification begins here}}
// CHECK: error: templates must have C++ linkage
// CHECK-NEXT: {{^}} void f(auto) {}
// CHECK-NEXT: {{^}} ^~~~~~~~~~~~{{$}}
void f(auto) {} // expected-error {{templates must have C++ linkage}}
void f(void) { // expected-note {{candidate function not viable: requires 0 arguments, but 1 was provided}}
f(1); // expected-error {{no matching function for call to 'f'}}
}
}
}
// Templates and partial and explicit specializations can't have C linkage.
namespace extern_c_templates {
template<typename T> struct A {
static int a;
struct b;
void c();
enum class d;
template<typename U> static int e;
template<typename U> struct f;
template<typename U> void g();
};
template<typename T> int B;
template<typename T> void C();
extern "C" { // expected-note 1+{{begins here}}
// templates
template<typename T> struct A; // expected-error {{templates must have C++ linkage}}
template<typename T> int B; // expected-error {{templates must have C++ linkage}}
template<typename T> void C(); // expected-error {{templates must have C++ linkage}}
// non-template members of a template
// FIXME: Should these really be valid?
template<typename T> int A<T>::a;
template<typename T> struct A<T>::b {};
template<typename T> void A<T>::c() {}
template<typename T> enum class A<T>::d {};
// templates
template<typename T> template<typename U> int A<T>::e; // expected-error {{templates must have C++ linkage}}
template<typename T> template<typename U> struct A<T>::f {}; // expected-error {{templates must have C++ linkage}}
template<typename T> template<typename U> void A<T>::g() {} // expected-error {{templates must have C++ linkage}}
// partial specializations
template<typename T> struct A<int*>; // expected-error {{templates must have C++ linkage}}
template<typename T> int B<int*>; // expected-error {{templates must have C++ linkage}}
template<typename T> template<typename U> int A<T>::e<U*>; // expected-error {{templates must have C++ linkage}}
template<typename T> template<typename U> struct A<T>::f<U*> {}; // expected-error {{templates must have C++ linkage}}
// explicit specializations of templates
template<> struct A<char> {}; // expected-error {{templates must have C++ linkage}}
template<> int B<char>; // expected-error {{templates must have C++ linkage}}
template<> void C<char>() {} // expected-error {{templates must have C++ linkage}}
// explicit specializations of members of a template
template<> int A<int>::a; // expected-error {{templates must have C++ linkage}}
template<> struct A<int>::b {}; // expected-error {{templates must have C++ linkage}}
template<> void A<int>::c() {} // expected-error {{templates must have C++ linkage}}
template<> enum class A<int>::d {}; // expected-error {{templates must have C++ linkage}}
// explicit specializations of member templates
template<> template<typename U> int A<int>::e; // expected-error {{templates must have C++ linkage}}
template<> template<typename U> struct A<int>::f {}; // expected-error {{templates must have C++ linkage}}
template<> template<typename U> void A<int>::g() {} // expected-error {{templates must have C++ linkage}}
}
// Provide valid definitions for the explicit instantiations below.
// FIXME: Our recovery from the invalid definitions above isn't very good.
template<typename T> template<typename U> int A<T>::e;
template<typename T> template<typename U> struct A<T>::f {};
template<typename T> template<typename U> void A<T>::g() {}
extern "C" {
// explicit instantiations
// FIXME: Should these really be valid?
template struct A<double>;
template int A<float>::a;
template struct A<float>::b;
template void A<float>::c();
template int A<float>::e<float>;
template struct A<float>::f<float>;
template void A<float>::g<float>();
}
}