diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-23 19:57:01 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-23 19:57:01 +0000 |
commit | a481ec4150ad203440852a2bfee0883dd26f7530 (patch) | |
tree | 5b39dca0a86ea1a9747f4731470c78b761efaba7 /lib/Sema/SemaTemplate.cpp | |
parent | 9ba6af8bedba28d10a6906c62c19d43f81c5d386 (diff) |
It turns out that people love using VLAs in templates, too. Weaken our
VLA restrictions so that one can use VLAs in templates (even
accidentally), but not as part of a non-type template parameter (which
would be very bad).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104471 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index ecac7a212a..307be9d786 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -534,6 +534,14 @@ void Sema::ActOnTypeParameterDefault(DeclPtrTy TypeParam, /// otherwise, produces a diagnostic and returns a NULL type. QualType Sema::CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc) { + // We don't allow variably-modified types as the type of non-type template + // parameters. + if (T->isVariablyModifiedType()) { + Diag(Loc, diag::err_variably_modified_nontype_template_param) + << T; + return QualType(); + } + // C++ [temp.param]p4: // // A non-type template-parameter shall have one of the following @@ -553,13 +561,6 @@ Sema::CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc) { // assume that it is well-formed. T->isDependentType()) return T; - // We don't allow variably-modified types as the type of non-type template - // parameters. - else if (T->isVariablyModifiedType()) { - Diag(Loc, diag::err_variably_modified_nontype_template_param) - << T; - return QualType(); - } // C++ [temp.param]p8: // // A non-type template-parameter of type "array of T" or |