forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang] Do not serialize function definitions without a body (llvm#12…
…1550) An instantiated templated function definition may not have a body due to parsing errors inside the templated function. When serializing, an assert is triggered inside `ASTRecordWriter::AddFunctionDefinition`. The instantiation may happen on an intermediate module. The test case was reduced from `mp-units`.
- Loading branch information
1 parent
3134045
commit a13bcf3
Showing
2 changed files
with
50 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,42 @@ | ||
// RUN: rm -rf %t | ||
// RUN: split-file %s %t | ||
// RUN: cd %t | ||
|
||
// RUN: %clang_cc1 -std=c++23 mod1.cppm -emit-module-interface -o mod1.pcm -fallow-pcm-with-compiler-errors -verify | ||
// RUN: %clang_cc1 -std=c++23 mod2.cppm -emit-module-interface -o mod2.pcm -fmodule-file=mod1=mod1.pcm -verify -fallow-pcm-with-compiler-errors | ||
// RUN: %clang_cc1 -std=c++23 mod3.cppm -emit-module-interface -o mod3.pcm -fmodule-file=mod1=mod1.pcm -fmodule-file=mod2=mod2.pcm -verify -fallow-pcm-with-compiler-errors | ||
// RUN: %clang_cc1 -std=c++23 main.cpp -fmodule-file=mod1=mod1.pcm -fmodule-file=mod2=mod2.pcm -fmodule-file=mod3=mod3.pcm -verify -fallow-pcm-with-compiler-errors -ast-dump-all | ||
|
||
//--- mod1.cppm | ||
export module mod1; | ||
|
||
export template <unsigned N, unsigned M> | ||
class A { | ||
public: | ||
constexpr A(const char[], const char[]) { | ||
auto x = BrokenExpr; // expected-error {{use of undeclared identifier 'BrokenExpr'}} | ||
} | ||
}; | ||
|
||
export template<A<1,1> NTTP> | ||
struct B {}; | ||
|
||
template < unsigned N, unsigned M > | ||
A(const char (&)[N], const char (&)[M]) -> A< 1, 1 >; | ||
|
||
//--- mod2.cppm | ||
export module mod2; | ||
import mod1; | ||
|
||
struct C: B <A{"a", "b"}> { // expected-error {{non-type template argument is not a constant expression}} | ||
constexpr C(int a) { } | ||
}; | ||
|
||
//--- mod3.cppm | ||
// expected-no-diagnostics | ||
export module mod3; | ||
export import mod2; | ||
|
||
//--- main.cpp | ||
// expected-no-diagnostics | ||
import mod3; // no crash |