Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AST] lookup in parent DeclContext for transparent DeclContext
The compiler would crash if we lookup for name in transparent decl context. See the tests attached for example. I think this should make sense since the member declared in transparent DeclContext are semantically defined in the enclosing (non-transparent) DeclContext, this is the definition for transparent DeclContext. Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D116792
- Loading branch information
1 parent
9ef2175
commit d9d63fc
Showing
4 changed files
with
29 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export module foo; | ||
export template <typename T> | ||
class X {}; |
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,11 @@ | ||
// RUN: rm -rf %t | ||
// RUN: mkdir -p %t | ||
// RUN: %clang_cc1 -std=c++20 %S/Inputs/template_name_lookup/foo.cppm -emit-module-interface -o %t/foo.pcm | ||
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only -verify | ||
|
||
import foo; | ||
void use() { | ||
X x; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'X'}} | ||
// expected-note@Inputs/template_name_lookup/foo.cppm:3 {{candidate template ignored: couldn't infer template argument 'T'}} | ||
// expected-note@Inputs/template_name_lookup/foo.cppm:3 {{candidate function template not viable: requires 1 argument, but 0 were provided}} | ||
} |
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,12 @@ | ||
// Tests that the lookup in transparent declaration context | ||
// (linkage specifiaction context) wouldn't cause compiler crash. | ||
// RUN: %clang_cc1 -std=c++20 %s -fsyntax-only -verify | ||
extern "C++" { | ||
template <class T> | ||
class X {}; // expected-note {{candidate template ignored: couldn't infer template argument 'T'}} | ||
// expected-note@-1 {{candidate function template not viable: requires 1 argument, but 0 were provided}} | ||
} | ||
|
||
void foo() { | ||
X x; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'X'}} | ||
} |