-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang][Sema] Fix crash when using name of UnresolvedUsingValueDecl w…
…ith template arguments (#83842) The following snippet causes a crash: ``` template<typename T> struct A : T { using T::f; void f(); void g() { f<int>(); // crash here } }; ``` This happens because we cast the result of `getAsTemplateNameDecl` as a `TemplateDecl` in `Sema::ClassifyName`, which we cannot do for an `UnresolvedUsingValueDecl`. This patch fixes the crash by considering a name to be that of a template if _any_ function declaration is found per [temp.names] p3.3.
- Loading branch information
1 parent
894f52f
commit a642eb8
Showing
4 changed files
with
42 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s | ||
|
||
template<typename T> | ||
struct A : T { | ||
using T::f; | ||
using T::g; | ||
using T::h; | ||
|
||
void f(); | ||
void g(); | ||
|
||
void i() { | ||
f<int>(); | ||
g<int>(); // expected-error{{no member named 'g' in 'A<B>'}} | ||
h<int>(); // expected-error{{expected '(' for function-style cast or type construction}} | ||
// expected-error@-1{{expected expression}} | ||
} | ||
}; | ||
|
||
struct B { | ||
template<typename T> | ||
void f(); | ||
|
||
void g(); | ||
|
||
template<typename T> | ||
void h(); | ||
}; | ||
|
||
template struct A<B>; // expected-note{{in instantiation of member function 'A<B>::i' requested here}} |