diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-02-10 21:40:29 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-02-10 21:40:29 +0000 |
| commit | d69f4f5b059ddbd77d7b7d1d6519ad69fb0535fc (patch) | |
| tree | 7285e31808c67241b14336b7941cc732d0e48328 /clang/lib/Sema/SemaDecl.cpp | |
| parent | d6979b8c38d412aeb6926712e2c88b861b2ce051 (diff) | |
| download | bcm5719-llvm-d69f4f5b059ddbd77d7b7d1d6519ad69fb0535fc.tar.gz bcm5719-llvm-d69f4f5b059ddbd77d7b7d1d6519ad69fb0535fc.zip | |
[c++1z] Require an initializer for deduced class template specialization types.
It's actually meaningful and useful to allow such variables to have no
initializer, but we are strictly following the standard here until the C++
committee reaches consensus on allowing this.
llvm-svn: 294785
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 2a082fc775b..17d58b156ba 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9816,7 +9816,15 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl, DeducedType *Deduced = Type->getContainedDeducedType(); assert(Deduced && "deduceVarTypeFromInitializer for non-deduced type"); - ArrayRef<Expr*> DeduceInits = Init ? ArrayRef<Expr*>(Init) : None; + // C++11 [dcl.spec.auto]p3 + if (!Init) { + assert(VDecl && "no init for init capture deduction?"); + Diag(VDecl->getLocation(), diag::err_auto_var_requires_init) + << VDecl->getDeclName() << Type; + return QualType(); + } + + ArrayRef<Expr*> DeduceInits = Init; if (DirectInit) { if (auto *PL = dyn_cast_or_null<ParenListExpr>(Init)) DeduceInits = PL->exprs(); @@ -9833,14 +9841,6 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl, InitsCopy); } - // C++11 [dcl.spec.auto]p3 - if (!Init) { - assert(VDecl && "no init for init capture deduction?"); - Diag(VDecl->getLocation(), diag::err_auto_var_requires_init) - << VDecl->getDeclName() << Type; - return QualType(); - } - if (DirectInit) { if (auto *IL = dyn_cast<InitListExpr>(Init)) DeduceInits = IL->inits(); |

