[PATCH] D113245: [Sema] Mark explicit specialization declaration in a friend invalid
Yuanfang Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 14 12:28:12 PST 2021
ychen updated this revision to Diff 394351.
ychen added a comment.
- Address Aaron's comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113245/new/
https://reviews.llvm.org/D113245
Files:
clang/lib/Sema/SemaDecl.cpp
clang/test/CXX/temp/temp.spec/temp.expl.spec/p20-2.cpp
Index: clang/test/CXX/temp/temp.spec/temp.expl.spec/p20-2.cpp
===================================================================
--- /dev/null
+++ clang/test/CXX/temp/temp.spec/temp.expl.spec/p20-2.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T>
+void f(T);
+
+template<typename T>
+struct A {
+ // expected-error at +1{{cannot declare an explicit specialization in a friend}}
+ template <> friend void f<>(int) {}
+};
+
+// Makes sure implicit instantiation here does not trigger
+// the assertion "Member specialization must be an explicit specialization"
+void foo(void) {
+ A<int> a;
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -9195,6 +9195,7 @@
<< Name << RemoveRange
<< FixItHint::CreateRemoval(RemoveRange)
<< FixItHint::CreateInsertion(InsertLoc, "<>");
+ Invalid = true;
}
}
} else {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113245.394351.patch
Type: text/x-patch
Size: 1063 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211214/b1dc7fc6/attachment.bin>
More information about the cfe-commits
mailing list