llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Artem Ershov (iam28th) <details> <summary>Changes</summary> The assersion failure, reported in https://github.com/llvm/llvm-project/issues/91131, doesn't fire since https://github.com/llvm/llvm-project/pull/92597 ; but that PR does not include a test for this case. Add a SemaTemplate regression test that verifies the invalid program emits the expected diagnostics without crashing. Note that a minimum patch to fix the original crash would be this: https://github.com/iam28th/llvm-project/commit/9d498c7e984e7c3a4f38a76d079146c4b290861a Fixes https://github.com/llvm/llvm-project/issues/91131 --- Full diff: https://github.com/llvm/llvm-project/pull/236018.diff 1 Files Affected: - (added) clang/test/SemaTemplate/gh91131.cpp (+24) ``````````diff diff --git a/clang/test/SemaTemplate/gh91131.cpp b/clang/test/SemaTemplate/gh91131.cpp new file mode 100644 index 00000000000000..2ea364562c6064 --- /dev/null +++ b/clang/test/SemaTemplate/gh91131.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template <typename T> +struct B : T {}; + +template <typename T> +struct A : B<T> {}; + +// expected-note@+1 {{attempt to specialize declaration here}} +struct C {}; // first declaration (valid and complete) + +// expected-error@+1 {{extraneous 'template<>' in declaration of struct 'C'}} +template <> +struct C {}; // second declaration (invalid) +// expected-error@-1 {{specialization of member 'C' does not specialize an instantiated member}} + +// crash before pull 92597: +// definition for C was retrieved via TagDecl::getDefinition (inherited by RecordDecl), +// which returned the first declaration because that declaraion is a complete definition; +// that definition wasn't invalid, so A<C> wasn't invalid as well; +// later assertion failed when layout for A<C> was built. +// +// was fixed in pull 92597: because it checks definition retrieved via CXXRecordDecl::getDefinition. +A<C> v; `````````` </details> https://github.com/llvm/llvm-project/pull/236018 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
