Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ Bug Fixes to C++ Support
diagnosing a failed cast caused indirectly by a failed implicit conversion to the type of the constructor parameter.
- Fixed an assertion failure by adjusting integral to boolean vector conversions (#GH108326)
- Mangle friend function templates with a constraint that depends on a template parameter from an enclosing template as members of the enclosing class. (#GH110247)
- Fixed an assertion failure when invoking recovery call expressions with explicit attributes
and undeclared templates. (#GH107047, #GH49093)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
10 changes: 9 additions & 1 deletion clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,15 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
LookupCtx ? LookupCtx : (SS.isEmpty() ? CurContext : nullptr);
while (DC) {
if (isa<CXXRecordDecl>(DC)) {
LookupQualifiedName(R, DC);
if (ExplicitTemplateArgs) {
if (LookupTemplateName(
R, S, SS, Context.getRecordType(cast<CXXRecordDecl>(DC)),
/*EnteringContext*/ false, TemplateNameIsRequired,
/*RequiredTemplateKind*/ nullptr, /*AllowTypoCorrection*/ true))
return true;
} else {
LookupQualifiedName(R, DC);
}

if (!R.empty()) {
// Don't give errors about ambiguities in this lookup.
Expand Down
32 changes: 32 additions & 0 deletions clang/test/SemaTemplate/recovery-crash-cxx20.cpp
Original file line number Diff line number Diff line change
@@ -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 {{declared as a non-template here}}
decltype(a< 0 >(0)) test; // expected-error {{'a' does not refer to a template}}
};

struct C {
static int a() { return 0; } // expected-note {{declared as a non-template here}}
decltype(a < 0 > (0)) test; // expected-error {{'a' does not refer to a template}}
};

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 {{declared as a non-template here}}
static constexpr int s = test< 1 >(); // expected-error {{'test' does not refer to a template}}
};
}