summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2012-01-05 22:34:08 +0000
committerEli Friedman <eli.friedman@gmail.com>2012-01-05 22:34:08 +0000
commitde30e523b40de486a385935550b43798eb4c77bf (patch)
treec80b7f9669cfb6cc20a5ea987ee0e3f03fbfdf40 /clang/lib/Sema/SemaDeclCXX.cpp
parentb3163e574e484f4fc625adbda71b5c9388a82a17 (diff)
downloadbcm5719-llvm-de30e523b40de486a385935550b43798eb4c77bf.tar.gz
bcm5719-llvm-de30e523b40de486a385935550b43798eb4c77bf.zip
Tweak the fix to PR8977: an empty expression-list represents value initialization, not default initialization. Fixes PR11712.
llvm-svn: 147620
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 46a47a22157..56b526b1d7e 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -8898,8 +8898,6 @@ void Sema::AddCXXDirectInitializerToDecl(Decl *RealDecl,
MultiExprArg Exprs,
SourceLocation RParenLoc,
bool TypeMayContainAuto) {
- assert(Exprs.size() != 0 && Exprs.get() && "missing expressions");
-
// If there is no declaration, there was an error parsing it. Just ignore
// the initializer.
if (RealDecl == 0)
@@ -8912,9 +8910,18 @@ void Sema::AddCXXDirectInitializerToDecl(Decl *RealDecl,
return;
}
- // C++0x [decl.spec.auto]p6. Deduce the type which 'auto' stands in for.
+ // C++0x [dcl.spec.auto]p6. Deduce the type which 'auto' stands in for.
if (TypeMayContainAuto && VDecl->getType()->getContainedAutoType()) {
- // FIXME: n3225 doesn't actually seem to indicate this is ill-formed
+ if (Exprs.size() == 0) {
+ // It isn't possible to write this directly, but it is possible to
+ // end up in this situation with "auto x(some_pack...);"
+ Diag(LParenLoc, diag::err_auto_var_init_no_expression)
+ << VDecl->getDeclName() << VDecl->getType()
+ << VDecl->getSourceRange();
+ RealDecl->setInvalidDecl();
+ return;
+ }
+
if (Exprs.size() > 1) {
Diag(Exprs.get()[1]->getSourceRange().getBegin(),
diag::err_auto_var_init_multiple_expressions)
OpenPOWER on IntegriCloud