From 5065864151d7c00292a42c978a39bdf81fe2c02c Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sun, 4 Sep 2011 20:24:20 +0000 Subject: [PATCH] PR10458: Last part of providing 'auto' type specifier as an extension in C++98: permit it within type-ids. llvm-svn: 139103 --- clang/lib/Parse/ParseDecl.cpp | 6 +++++- .../test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index ad649a3c2250..4928bde0022b 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -2265,7 +2265,11 @@ bool Parser::ParseOptionalTypeSpecifier(DeclSpec &DS, bool& isInvalid, // C++0x auto support. case tok::kw_auto: - if (!getLang().CPlusPlus0x) + // This is only called in situations where a storage-class specifier is + // illegal, so we can assume an auto type specifier was intended even in + // C++98. In C++98 mode, DeclSpec::Finish will produce an appropriate + // extension diagnostic. + if (!getLang().CPlusPlus) return false; isInvalid = DS.SetTypeSpecType(DeclSpec::TST_auto, Loc, PrevSpec, DiagID); diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp index 856c707a7fa4..d5d0952aa858 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp @@ -20,10 +20,7 @@ void f() { for (; auto a = false; ) { } - // FIXME: support 'auto' error recovery here in pre-C++0x mode. -#if __has_feature(cxx_auto_type) new const auto (0); -#endif new (auto) (0.0); int arr[] = {1, 2, 3}; -- GitLab