File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -7230,6 +7230,10 @@ void ASTWriter::CompletedImplicitDefinition(const FunctionDecl *D) {
7230
7230
if (!D->isFromASTFile ())
7231
7231
return ; // Declaration not imported from PCH.
7232
7232
7233
+ // The function definition may not have a body due to parsing errors.
7234
+ if (!D->doesThisDeclarationHaveABody ())
7235
+ return ;
7236
+
7233
7237
// Implicit function decl from a PCH was defined.
7234
7238
DeclUpdates[D].push_back (DeclUpdate (UPD_CXX_ADDED_FUNCTION_DEFINITION));
7235
7239
}
@@ -7249,6 +7253,10 @@ void ASTWriter::FunctionDefinitionInstantiated(const FunctionDecl *D) {
7249
7253
if (!D->isFromASTFile ())
7250
7254
return ;
7251
7255
7256
+ // The function definition may not have a body due to parsing errors.
7257
+ if (!D->doesThisDeclarationHaveABody ())
7258
+ return ;
7259
+
7252
7260
DeclUpdates[D].push_back (DeclUpdate (UPD_CXX_ADDED_FUNCTION_DEFINITION));
7253
7261
}
7254
7262
Original file line number Diff line number Diff line change
1
+ // RUN: rm -rf %t
2
+ // RUN: split-file %s %t
3
+ // RUN: cd %t
4
+
5
+ // RUN: %clang_cc1 -std=c++23 mod1.cppm -emit-module-interface -o mod1.pcm -fallow-pcm-with-compiler-errors -verify
6
+ // 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
7
+ // 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
8
+ // 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
9
+
10
+ // --- mod1.cppm
11
+ export module mod1;
12
+
13
+ export template <unsigned N, unsigned M>
14
+ class A {
15
+ public:
16
+ constexpr A (const char [], const char []) {
17
+ auto x = BrokenExpr; // expected-error {{use of undeclared identifier 'BrokenExpr'}}
18
+ }
19
+ };
20
+
21
+ export template <A<1 ,1 > NTTP>
22
+ struct B {};
23
+
24
+ template < unsigned N, unsigned M >
25
+ A (const char (&)[N], const char (&)[M]) -> A< 1, 1 >;
26
+
27
+ // --- mod2.cppm
28
+ export module mod2;
29
+ import mod1;
30
+
31
+ struct C : B <A{" a" , " b" }> { // expected-error {{non-type template argument is not a constant expression}}
32
+ constexpr C (int a) { }
33
+ };
34
+
35
+ // --- mod3.cppm
36
+ // expected-no-diagnostics
37
+ export module mod3;
38
+ export import mod2;
39
+
40
+ // --- main.cpp
41
+ // expected-no-diagnostics
42
+ import mod3; // no crash
You can’t perform that action at this time.
0 commit comments