xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/array-to-pointer-decay.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc // expected-no-diagnostics
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc struct mystruct {
5*f4a2713aSLionel Sambuc   int  member;
6*f4a2713aSLionel Sambuc };
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc template <int i>
foo()9*f4a2713aSLionel Sambuc int foo() {
10*f4a2713aSLionel Sambuc   mystruct s[1];
11*f4a2713aSLionel Sambuc   return s->member;
12*f4a2713aSLionel Sambuc }
13*f4a2713aSLionel Sambuc 
main()14*f4a2713aSLionel Sambuc int main() {
15*f4a2713aSLionel Sambuc   foo<1>();
16*f4a2713aSLionel Sambuc }
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc // PR7405
19*f4a2713aSLionel Sambuc struct hb_sanitize_context_t {
20*f4a2713aSLionel Sambuc   int start;
21*f4a2713aSLionel Sambuc };
sanitize()22*f4a2713aSLionel Sambuc template <typename Type> static bool sanitize() {
23*f4a2713aSLionel Sambuc   hb_sanitize_context_t c[1];
24*f4a2713aSLionel Sambuc   return !c->start;
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc bool closure = sanitize<int>();
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc // PR16206
29*f4a2713aSLionel Sambuc typedef struct {
30*f4a2713aSLionel Sambuc 	char x[4];
31*f4a2713aSLionel Sambuc } chars;
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc chars getChars();
34*f4a2713aSLionel Sambuc void use(char *);
35*f4a2713aSLionel Sambuc 
test()36*f4a2713aSLionel Sambuc void test() {
37*f4a2713aSLionel Sambuc 	use(getChars().x);
38*f4a2713aSLionel Sambuc }
39