Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -10395,12 +10395,22 @@ // 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(); + + // Except for class argument deduction, and then for an initializing + // declaration only, i.e. no static at class scope or extern. + if (!isa(Deduced) || + VDecl->hasExternalStorage() || + VDecl->isStaticDataMember()) { + Diag(VDecl->getLocation(), diag::err_auto_var_requires_init) + << VDecl->getDeclName() << Type; + return QualType(); + } } - ArrayRef DeduceInits = Init; + ArrayRef DeduceInits; + if (Init) + DeduceInits = Init; + if (DirectInit) { if (auto *PL = dyn_cast_or_null(Init)) DeduceInits = PL->exprs(); Index: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp =================================================================== --- test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp +++ test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp @@ -5,8 +5,7 @@ A(int) -> A; static constexpr inline const volatile A a = {}; // ok, specifiers are permitted -// FIXME: There isn't really a good reason to reject this. -A b; // expected-error {{requires an initializer}} +A b; A c [[]] {}; A d = {}, e = {}; Index: test/Parser/cxx1z-class-template-argument-deduction.cpp =================================================================== --- test/Parser/cxx1z-class-template-argument-deduction.cpp +++ test/Parser/cxx1z-class-template-argument-deduction.cpp @@ -137,7 +137,6 @@ (void)A{n}; (void)new A(n); (void)new A{n}; - // FIXME: We should diagnose the lack of an initializer here. (void)new A; } } @@ -150,7 +149,7 @@ auto k() -> A; // expected-error{{requires template arguments}} - A a; // expected-error {{declaration of variable 'a' with deduced type 'A' requires an initializer}} + A a; A b = 0; const A c = 0; A (parens) = 0; // expected-error {{cannot use parentheses when declaring variable with deduced class template specialization type}}