summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-07-11 00:34:39 +0000
committerAnders Carlsson <andersca@mac.com>2009-07-11 00:34:39 +0000
commitae01993a12d609702087b8bcc7e0a3a853851127 (patch)
tree1c27d2b268e150230e967df6b8f2eb70c65046c7 /clang/lib/Sema/SemaDecl.cpp
parentf5145921975c4b6a3d986ed34ab716d4dadeb8f9 (diff)
downloadbcm5719-llvm-ae01993a12d609702087b8bcc7e0a3a853851127.tar.gz
bcm5719-llvm-ae01993a12d609702087b8bcc7e0a3a853851127.zip
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.
llvm-svn: 75322
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 2c24dc976e3..9c3ef2f6da2 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/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
OpenPOWER on IntegriCloud