diff options
| author | Douglas Gregor <dgregor@apple.com> | 2009-11-19 18:03:26 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2009-11-19 18:03:26 +0000 |
| commit | ad2956c25d5f549777b8f5b728277cf0cdbf7275 (patch) | |
| tree | 524625af4765c30f4dd77fac5ba3388a3f877787 /clang/test/SemaTemplate/dependent-sized_array.cpp | |
| parent | 1d9f1fe7cc0eb6875630aaf34efa259a8ae16e0e (diff) | |
| download | bcm5719-llvm-ad2956c25d5f549777b8f5b728277cf0cdbf7275.tar.gz bcm5719-llvm-ad2956c25d5f549777b8f5b728277cf0cdbf7275.zip | |
Cope with an amusingly little anomaly with dependent types and
incomplete array initialization, where we have the following in a
template:
int a[] = { 1, 2, something-value-dependent };
// ...
sizeof(a);
The type of "a" appears to be a non-dependent IncompleteArrayType, but
treating it as such makes the sizeof(a) fail at template definition
time. We now correctly handle this by morphing the IncompleteArrayType
into a DependentSizedArrayType with a NULL expression, indicating that
its size has no corresponding expression (and, therefore, the type is
distinct from others).
llvm-svn: 89366
Diffstat (limited to 'clang/test/SemaTemplate/dependent-sized_array.cpp')
| -rw-r--r-- | clang/test/SemaTemplate/dependent-sized_array.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/dependent-sized_array.cpp b/clang/test/SemaTemplate/dependent-sized_array.cpp new file mode 100644 index 00000000000..77b2bdce30f --- /dev/null +++ b/clang/test/SemaTemplate/dependent-sized_array.cpp @@ -0,0 +1,10 @@ +// RUN: clang-cc -fsyntax-only -verify %s + +template<int N> +void f() { + int a[] = { 1, 2, 3, N }; + unsigned numAs = sizeof(a) / sizeof(int); +} + +template void f<17>(); + |

