Fix bugs checking va_start in lambdas and erroneous contexts
authorReid Kleckner <rnk@google.com>
Thu, 4 May 2017 19:51:05 +0000 (19:51 +0000)
committerReid Kleckner <rnk@google.com>
Thu, 4 May 2017 19:51:05 +0000 (19:51 +0000)
commitf1deb837eee39ec6ddbe177be9de129f4fd59ee1
treeda123b2ab5fec9c0a7ad332a4a5ff2a97cc1d2ea
parentdea97cfbf9515b7732e54530649495172470bf55
Fix bugs checking va_start in lambdas and erroneous contexts

Summary:
First, getCurFunction looks through blocks and lambdas, which is wrong.
Inside a lambda, va_start should refer to the lambda call operator
prototype. This fixes PR32737.

Second, we shouldn't use any of the getCur* methods, because they look
through contexts that we don't want to look through (EnumDecl,
CapturedStmtDecl). We can use CurContext directly as the calling
context.

Finally, this code assumed that CallExprs would never appear outside of
code contexts (block, function, obj-c method), which is wrong. Struct
member initializers are an easy way to create and parse exprs in a
non-code context.

Reviewers: rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D32761

llvm-svn: 302188
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/OpenMP/varargs.cpp [new file with mode: 0644]
clang/test/SemaCXX/varargs.cpp