llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Oleksandr T. (a-tarasyuk) <details> <summary>Changes</summary> Fixes #<!-- -->107047 Fixes #<!-- -->49093 --- Full diff: https://github.com/llvm/llvm-project/pull/107786.diff 3 Files Affected: - (modified) clang/docs/ReleaseNotes.rst (+2-1) - (modified) clang/lib/Sema/SemaTemplate.cpp (+6) - (added) clang/test/SemaTemplate/recovery-crash-cxx20.cpp (+32) ``````````diff diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f7c3194c91fa31..f96045c57e7a0d 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -376,8 +376,9 @@ Bug Fixes to C++ Support - Fixed a bug in the substitution of empty pack indexing types. (#GH105903) - Clang no longer tries to capture non-odr used default arguments of template parameters of generic lambdas (#GH107048) - Fixed a bug where defaulted comparison operators would remove ``const`` from base classes. (#GH102588) - - Fix a crash when using ``source_location`` in the trailing return type of a lambda expression. (#GH67134) +- Fixed an assertion failure when invoking recovery call expressions with explicit attributes + and undeclared templates. (#GH107047, #GH49093) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 513f83146fb59e..1ec6219bbd6ea8 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -4458,6 +4458,12 @@ ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS, R.getAsSingle<ConceptDecl>(), TemplateArgs); } + if (TemplateArgs && R.getAsSingle<FunctionDecl>()) { + if (R.getAsSingle<FunctionDecl>()->getTemplateSpecializationKind() == + TemplateSpecializationKind::TSK_Undeclared) + return ExprError(); + } + // We don't want lookup warnings at this point. R.suppressDiagnostics(); diff --git a/clang/test/SemaTemplate/recovery-crash-cxx20.cpp b/clang/test/SemaTemplate/recovery-crash-cxx20.cpp new file mode 100644 index 00000000000000..dd92ddcd36ab02 --- /dev/null +++ b/clang/test/SemaTemplate/recovery-crash-cxx20.cpp @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s + +namespace GH49093 { + class B { + public: + static int a() { return 0; } // expected-note {{member is declared here}} + decltype(a< 0 >(0)) test; // expected-error {{member 'a' used before its declaration}} + }; + + struct C { + static int a() { return 0; } // expected-note {{member is declared here}} + decltype(a < 0 > (0)) test; // expected-error {{member 'a' used before its declaration}} + }; + + void test_is_bool(bool t) {} + void test_is_bool(int t) {} + + int main() { + B b; + test_is_bool(b.test); + + C c; + test_is_bool(c.test); + } +} + +namespace GH107047 { + struct A { + static constexpr auto test() { return 1; } // expected-note {{member is declared here}} + static constexpr int s = test< 1 >(); // expected-error {{member 'test' used before its declaration}} + }; +} `````````` </details> https://github.com/llvm/llvm-project/pull/107786 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits