[clang] 30b676a - Don't crash when code completing `using enum ^Foo`.
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 25 19:52:30 PDT 2022
Author: Sam McCall
Date: 2022-09-26T04:52:19+02:00
New Revision: 30b676ac5f3041a5494b1eb9c9a3322cfc56d480
URL: https://github.com/llvm/llvm-project/commit/30b676ac5f3041a5494b1eb9c9a3322cfc56d480
DIFF: https://github.com/llvm/llvm-project/commit/30b676ac5f3041a5494b1eb9c9a3322cfc56d480.diff
LOG: Don't crash when code completing `using enum ^Foo`.
Fixes https://github.com/clangd/clangd/issues/1281
Differential Revision: https://reviews.llvm.org/D134243
Added:
clang/test/CodeCompletion/using-enum.cpp
Modified:
clang/lib/Parse/ParseDecl.cpp
Removed:
################################################################################
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index d6a2a08bf28b7..4d25b22c9cd33 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4593,6 +4593,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
// Code completion for an enum name.
cutOffParsing();
Actions.CodeCompleteTag(getCurScope(), DeclSpec::TST_enum);
+ DS.SetTypeSpecError(); // Needed by ActOnUsingDeclaration.
return;
}
diff --git a/clang/test/CodeCompletion/using-enum.cpp b/clang/test/CodeCompletion/using-enum.cpp
new file mode 100644
index 0000000000000..1619e36c18f61
--- /dev/null
+++ b/clang/test/CodeCompletion/using-enum.cpp
@@ -0,0 +1,7 @@
+enum class AAA { X, Y, Z };
+
+namespace N2 {
+ using enum AAA;
+ // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:14 %s | FileCheck -check-prefix=CHECK-CC1 %s
+ // CHECK-CC1: COMPLETION: AAA
+};
More information about the cfe-commits
mailing list