annotate clang/test/SemaTemplate/dependent-sized_array.cpp @ 236:c4bab56944e8 llvm-original

LLVM 16
author kono
date Wed, 09 Nov 2022 17:45:10 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 template<int N>
anatofuz
parents:
diff changeset
4 void f() {
anatofuz
parents:
diff changeset
5 int a[] = { 1, 2, 3, N };
anatofuz
parents:
diff changeset
6 unsigned numAs = sizeof(a) / sizeof(int);
anatofuz
parents:
diff changeset
7 }
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 template void f<17>();
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 template<int N>
anatofuz
parents:
diff changeset
13 void f1() {
anatofuz
parents:
diff changeset
14 int a0[] = {}; // expected-warning{{zero}}
anatofuz
parents:
diff changeset
15 int a1[] = { 1, 2, 3, N };
anatofuz
parents:
diff changeset
16 int a3[sizeof(a1)/sizeof(int) != 4? 1 : -1]; // expected-error{{negative}}
anatofuz
parents:
diff changeset
17 }
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 namespace PR13788 {
anatofuz
parents:
diff changeset
20 template <unsigned __N>
anatofuz
parents:
diff changeset
21 struct S {
anatofuz
parents:
diff changeset
22 int V;
anatofuz
parents:
diff changeset
23 };
anatofuz
parents:
diff changeset
24 template <int N>
anatofuz
parents:
diff changeset
25 void foo() {
anatofuz
parents:
diff changeset
26 S<0> arr[N] = {{ 4 }};
anatofuz
parents:
diff changeset
27 }
anatofuz
parents:
diff changeset
28 }