]> granicus.if.org Git - clang/commit
P0305R1: Parsing support for init-statements in 'if' and 'switch' statements.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 29 Jun 2016 21:17:59 +0000 (21:17 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 29 Jun 2016 21:17:59 +0000 (21:17 +0000)
commit24d543be3689fba09cd4afd3fc7f05b930c563a8
treebf8d18cd04f80d281234f12722ed1192618a3eaf
parent21ae2c7c2e7179fa49c06843d22a8392845f3983
P0305R1: Parsing support for init-statements in 'if' and 'switch' statements.
No semantic analysis yet.

This is a pain to disambiguate correctly, because the parsing rules for the
declaration form of a condition and of an init-statement are quite different --
for a token sequence that looks like a declaration, we frequently need to
disambiguate all the way to the ')' or ';'.

We could do better here in some cases by stopping disambiguation once we've
decided whether we've got an expression or not (rather than keeping going until
we know whether it's an init-statement declaration or a condition declaration),
by unifying our parsing code for the two types of declaration and moving the
syntactic checks into Sema; if this has a measurable impact on parsing
performance, I'll look into that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274169 91177308-0d34-0410-b5e6-96231b3b80d8
13 files changed:
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Parse/Parser.h
include/clang/Sema/DeclSpec.h
include/clang/Sema/Sema.h
lib/Parse/ParseDecl.cpp
lib/Parse/ParseExprCXX.cpp
lib/Parse/ParseStmt.cpp
lib/Parse/ParseTentative.cpp
lib/Sema/SemaStmt.cpp
lib/Sema/SemaType.cpp
lib/Sema/TreeTransform.h
test/Parser/cxx1z-init-statement.cpp [new file with mode: 0644]
test/Parser/extra-semi.cpp