From c94b4b5031a1b1eab1e984c0ad9b00af77ab4f37 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 28 Jun 2016 23:26:18 +0000 Subject: [PATCH] Function declarations are, in fact, permitted in the init-statement of a for loop. Don't confuse Sema by saying they're not. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274080 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/DeclSpec.h | 2 +- test/SemaCXX/cxx1y-deduced-return-type.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index c71419f281..09aabda380 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -2119,9 +2119,9 @@ public: case FileContext: case MemberContext: case BlockContext: + case ForContext: return true; - case ForContext: case ConditionContext: case KNRTypeListContext: case TypeNameContext: diff --git a/test/SemaCXX/cxx1y-deduced-return-type.cpp b/test/SemaCXX/cxx1y-deduced-return-type.cpp index e3f6f96801..593ec48b43 100644 --- a/test/SemaCXX/cxx1y-deduced-return-type.cpp +++ b/test/SemaCXX/cxx1y-deduced-return-type.cpp @@ -502,3 +502,7 @@ namespace PR24989 { using T = decltype(x); void (T::*p)(int) const = &T::operator(); } + +void forinit_decltypeauto() { + for (decltype(auto) forinit_decltypeauto_inner();;) {} // expected-warning {{interpreted as a function}} expected-note {{replace}} +} -- 2.40.0