Author: Erich Keane Date: 2022-09-23T12:21:56-07:00 New Revision: 0d18815baf6dffa682b0966f311041cfc7d8ff6d
URL: https://github.com/llvm/llvm-project/commit/0d18815baf6dffa682b0966f311041cfc7d8ff6d DIFF: https://github.com/llvm/llvm-project/commit/0d18815baf6dffa682b0966f311041cfc7d8ff6d.diff LOG: Fix GH57943: Friend constraint checker didn't handle null decls. Apparently TransformDecl in TreeTransform can be called with a nullptr for a Decl, so my casts were illegal. The fix here is to add an early exit to my TransformDecl. Added: clang/test/SemaTemplate/gh57943.cpp Modified: clang/lib/Sema/SemaTemplate.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 68af353e2cc5c..cf501adbe1174 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -1716,6 +1716,8 @@ class ConstraintRefersToContainingTemplateChecker } Decl *TransformDecl(SourceLocation Loc, Decl *D) { + if (!D) + return D; // FIXME : This is possibly an incomplete list, but it is unclear what other // Decl kinds could be used to refer to the template parameters. This is a // best guess so far based on examples currently available, but the diff --git a/clang/test/SemaTemplate/gh57943.cpp b/clang/test/SemaTemplate/gh57943.cpp new file mode 100644 index 0000000000000..5a9f6f4d09f8a --- /dev/null +++ b/clang/test/SemaTemplate/gh57943.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s +// expected-no-diagnostics +struct s { + template<typename T> + requires requires(T x) { x.g(); } + friend void f(T); +}; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits