diff options
author | Anders Carlsson <andersca@mac.com> | 2009-07-11 00:34:39 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-07-11 00:34:39 +0000 |
commit | 6a75cd9c1d54625fca7b5477ab9545bcdbd85ea4 (patch) | |
tree | 6dfd55ed4a291d2126b9a954d6f5346b2779b873 /lib/Sema/SemaDecl.cpp | |
parent | 496e89f8d55f7a931c246e820c10f7296a246ac2 (diff) |
Implement more of C++0x 'auto'. A variable with an auto type specifier must have an initializer. Also, move some tests around to match the C++0x draft better.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75322 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 2c24dc976e..9c3ef2f6da 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2756,7 +2756,8 @@ void Sema::AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit) { return; } -void Sema::ActOnUninitializedDecl(DeclPtrTy dcl) { +void Sema::ActOnUninitializedDecl(DeclPtrTy dcl, + bool TypeContainsUndeducedAuto) { Decl *RealDecl = dcl.getAs<Decl>(); // If there is no declaration, there was an error parsing it. Just ignore it. @@ -2784,6 +2785,14 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl) { return; } + // C++0x [dcl.spec.auto]p3 + if (TypeContainsUndeducedAuto) { + Diag(Var->getLocation(), diag::err_auto_var_requires_init) + << Var->getDeclName() << Type; + Var->setInvalidDecl(); + return; + } + // C++ [dcl.init]p9: // // If no initializer is specified for an object, and the object |