llvm-project/clang/test/Parser/switch-typo-correction.cpp
Haojian Wu 386f95e168 [Parser] Fix the assertion crash in ActOnStartOfSwitch stmt.
Summary:
After we parse the switch condition, we don't do the type check for
type-dependent expr (e.g. TypoExpr) (in Sema::CheckSwitchCondition), then the
TypoExpr is corrected to an invalid-type expr (in Sema::MakeFullExpr) and passed
to the ActOnStartOfSwitchStmt, which triggers the assertion.

Fix https://github.com/clangd/clangd/issues/311

Reviewers: sammccall

Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D76592
2020-03-24 15:17:04 +01:00

10 lines
283 B
C++

// RUN: %clang_cc1 -fsyntax-only -verify %s
namespace c { double xxx; } // expected-note{{'c::xxx' declared here}}
namespace d { float xxx; }
namespace z { namespace xxx {} }
void crash() {
switch (xxx) {} // expected-error{{use of undeclared identifier 'xxx'; did you mean }}
}