-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C++20] [Modules] Handle reachability for deduction guide
Previously, we forget to handle reachability for deduction guide. The deduction guide is a hint to the compiler. And the deduction guide should be able to use if the corresponding template decl is reachable.
- Loading branch information
1 parent
11079e8
commit 4983fdf
Showing
4 changed files
with
88 additions
and
0 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,30 @@ | ||
// RUN: rm -rf %t | ||
// RUN: mkdir %t | ||
// RUN: split-file %s %t | ||
// | ||
// RUN: %clang_cc1 -std=c++20 %t/Templ.cppm -emit-module-interface -o %t/Templ.pcm | ||
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only | ||
|
||
//--- foo.h | ||
template <typename T> | ||
class Templ { | ||
public: | ||
Templ(T a) {} | ||
}; | ||
|
||
template<typename T> | ||
Templ(T t) -> Templ<T>; | ||
|
||
//--- Templ.cppm | ||
module; | ||
#include "foo.h" | ||
export module Templ; | ||
export using ::Templ; | ||
|
||
//--- Use.cpp | ||
// expected-no-diagnostics | ||
import Templ; | ||
void func() { | ||
Templ t(5); | ||
} | ||
|
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,25 @@ | ||
// RUN: rm -rf %t | ||
// RUN: mkdir %t | ||
// RUN: split-file %s %t | ||
// | ||
// RUN: %clang_cc1 -std=c++20 %t/Templ.cppm -emit-module-interface -o %t/Templ.pcm | ||
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only | ||
|
||
//--- Templ.cppm | ||
export module Templ; | ||
export template <typename T> | ||
class Templ { | ||
public: | ||
Templ(T a) {} | ||
}; | ||
|
||
template<typename T> | ||
Templ(T t) -> Templ<T>; | ||
|
||
//--- Use.cpp | ||
// expected-no-diagnostics | ||
import Templ; | ||
void func() { | ||
Templ t(5); | ||
} | ||
|
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,26 @@ | ||
// RUN: rm -rf %t | ||
// RUN: mkdir %t | ||
// RUN: split-file %s %t | ||
// | ||
// RUN: %clang_cc1 -std=c++20 %t/Templ.cppm -emit-module-interface -o %t/Templ.pcm | ||
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only | ||
|
||
//--- Templ.cppm | ||
export module Templ; | ||
template <typename T> | ||
class Templ { | ||
public: | ||
Templ(T a) {} | ||
}; | ||
|
||
template<typename T> | ||
Templ(T t) -> Templ<T>; | ||
|
||
//--- Use.cpp | ||
import Templ; | ||
void func() { | ||
Templ t(5); // expected-error {{declaration of 'Templ' must be imported from module 'Templ' before it is required}} | ||
// expected-error@-1 {{unknown type name 'Templ'}} | ||
// expected-note@Templ.cppm:3 {{declaration here is not visible}} | ||
} | ||
|