diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-05-15 21:27:30 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2018-05-15 21:27:30 +0000 |
| commit | 7bfd70549268e99138b8397c7725056ce7ba7655 (patch) | |
| tree | 65a507cd03f969354403e2e24329b2b111c43efc /clang | |
| parent | 651d0bf9dc6165cad9767ef77fdfdb8c169d60a4 (diff) | |
| download | bcm5719-llvm-7bfd70549268e99138b8397c7725056ce7ba7655.tar.gz bcm5719-llvm-7bfd70549268e99138b8397c7725056ce7ba7655.zip | |
Don't produce a redundant "auto type is incompatible with C++98" on every lambda with no explicit return type.
We already warned about the lambda, and we don't have a source location for the imagined "auto" anyway.
llvm-svn: 332401
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaType.cpp | 4 | ||||
| -rw-r--r-- | clang/test/SemaCXX/cxx98-compat.cpp | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index b13570f97bf..b51d49461fe 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2962,9 +2962,11 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, T = SemaRef.Context.IntTy; D.setInvalidType(true); - } else if (!HaveTrailing) { + } else if (!HaveTrailing && + D.getContext() != DeclaratorContext::LambdaExprContext) { // If there was a trailing return type, we already got // warn_cxx98_compat_trailing_return_type in the parser. + // If this was a lambda, we already warned on that too. SemaRef.Diag(AutoRange.getBegin(), diag::warn_cxx98_compat_auto_type_specifier) << AutoRange; diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp index 33516f70687..ed2666036a1 100644 --- a/clang/test/SemaCXX/cxx98-compat.cpp +++ b/clang/test/SemaCXX/cxx98-compat.cpp @@ -47,6 +47,8 @@ namespace TemplateParsing { void Lambda() { []{}(); // expected-warning {{lambda expressions are incompatible with C++98}} + // Don't warn about implicit "-> auto" here. + [](){}(); // expected-warning {{lambda expressions are incompatible with C++98}} } struct Ctor { |

