[Clang] ensure mangled names are valid identifiers before being suggested in ifunc...
[llvm-project.git] / clang / test / Modules / redecl-templates.cpp
blob3ebafb53dc3bc510a11a378edce9f102b1496c8f
1 // RUN: rm -rf %t
2 // RUN: %clang_cc1 -x c++ -I %S/Inputs/redecl-templates %s -verify -std=c++14
3 // RUN: %clang_cc1 -x c++ -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/redecl-templates %s -verify -std=c++14
5 template<int N> struct A {};
6 template<int N> using X = A<N>;
8 template<int N> constexpr void f() {}
9 template<int N> constexpr void g() { f<N>(); }
11 template<int N> extern int v;
12 template<int N> int &w = v<N>;
14 #include "a.h"
16 // Be careful not to mention A here, that'll import the decls from "a.h".
17 int g(X<1> *);
18 X<1> *p = 0;
20 // This will implicitly instantiate A<1> if we haven't imported the explicit
21 // specialization declaration from "a.h".
22 int k = g(p);
23 // Likewise for f and v.
24 void h() { g<1>(); }
25 int &x = w<1>;
27 // This is OK: we declared the explicit specialization before we triggered
28 // instantiation of this specialization.
29 template<> struct A<1> {};
30 template<> constexpr void f<1>() {}
31 // Variable template explicit specializations are always definitions unless they
32 // are static data members declared without an initializer.
33 template<> int v<1>; // expected-error {{redefinition of 'v<1>'}}
34 // expected-note@Inputs/redecl-templates/a.h:8 {{previous definition is here}}