[PATCH] D127638: [clang][sema] Provide better diagnostic for missing template parameters
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 13 22:13:37 PDT 2022
tbaeder updated this revision to Diff 436650.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127638/new/
https://reviews.llvm.org/D127638
Files:
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/test/SemaCXX/nested-name-spec.cpp
Index: clang/test/SemaCXX/nested-name-spec.cpp
===================================================================
--- clang/test/SemaCXX/nested-name-spec.cpp
+++ clang/test/SemaCXX/nested-name-spec.cpp
@@ -473,3 +473,10 @@
x: goto x;
}
}
+
+template <typename T>
+struct x; // expected-note {{template is declared here}}
+
+template <typename T>
+int issue55962 = x::a; // expected-error {{use of class template 'x' requires template arguments}} \
+ // expected-warning {{variable templates are a C++14 extension}}
Index: clang/lib/Sema/SemaCXXScopeSpec.cpp
===================================================================
--- clang/lib/Sema/SemaCXXScopeSpec.cpp
+++ clang/lib/Sema/SemaCXXScopeSpec.cpp
@@ -828,10 +828,14 @@
}
if (!Found.empty()) {
- if (TypeDecl *TD = Found.getAsSingle<TypeDecl>())
+ if (TypeDecl *TD = Found.getAsSingle<TypeDecl>()) {
Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
<< Context.getTypeDeclType(TD) << getLangOpts().CPlusPlus;
- else {
+ } else if (TemplateDecl *TD = Found.getAsSingle<TemplateDecl>()) {
+ ParsedType SuggestedType;
+ DiagnoseUnknownTypeName(IdInfo.Identifier, IdInfo.IdentifierLoc, S, &SS,
+ SuggestedType);
+ } else {
Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
<< IdInfo.Identifier << getLangOpts().CPlusPlus;
if (NamedDecl *ND = Found.getAsSingle<NamedDecl>())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127638.436650.patch
Type: text/x-patch
Size: 1497 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220614/810a8b92/attachment.bin>
More information about the cfe-commits
mailing list