Skip to content

Commit 7a98e78

Browse files
committed
Use split-file for the lit test
1 parent 71c8699 commit 7a98e78

File tree

6 files changed

+34
-21
lines changed

6 files changed

+34
-21
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ Improvements to Clang's diagnostics
256256

257257
- Improve the diagnostics for shadows template parameter to report correct location (#GH129060).
258258

259+
- Improve the ``-Wundefined-func-template`` warning when a function template is not instantiated due to being unreachable in modules.
260+
259261
Improvements to Clang's time-trace
260262
----------------------------------
261263

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ bool Sema::DiagnoseUninstantiableTemplate(
763763
SourceLocation PointOfInstantiation, NamedDecl *Instantiation,
764764
bool InstantiatedFromMember, const NamedDecl *Pattern,
765765
const NamedDecl *PatternDef, TemplateSpecializationKind TSK,
766-
bool Complain /*= true*/, bool *Unreachable) {
766+
bool Complain, bool *Unreachable) {
767767
assert(isa<TagDecl>(Instantiation) || isa<FunctionDecl>(Instantiation) ||
768768
isa<VarDecl>(Instantiation));
769769

clang/test/Modules/Inputs/undefined-template/hoge.h

Lines changed: 0 additions & 7 deletions
This file was deleted.

clang/test/Modules/Inputs/undefined-template/module.modulemap

Lines changed: 0 additions & 7 deletions
This file was deleted.

clang/test/Modules/Inputs/undefined-template/shared_ptr2.h

Lines changed: 0 additions & 4 deletions
This file was deleted.

clang/test/Modules/diag-undefined-template.cpp

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,37 @@
11
// RUN: rm -rf %t
2-
// RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -I%S/Inputs/undefined-template \
2+
// RUN: split-file %s %t
3+
// RUN: %clang_cc1 -std=c++20 -fmodules -fmodules-cache-path=%t -I%t \
34
// RUN: -Wundefined-func-template \
4-
// RUN: -fimplicit-module-maps %s 2>&1 | grep "unreachable declaration of template entity is her"
5+
// RUN: -fimplicit-module-maps %t/main.cpp 2>&1 | grep "unreachable declaration of template entity is here"
56

7+
// Note that the diagnostics are triggered when building the 'hoge' module, which is imported from the main file.
8+
// The "-verify" flag doesn't work in this case. Instead, we grep the expected text to verify the test.
9+
10+
//--- shared_ptr2.h
11+
#pragma once
12+
13+
template<class T>
14+
void x() { }
15+
16+
//--- hoge.h
17+
#pragma once
18+
19+
#include "shared_ptr2.h"
20+
21+
inline void f() {
22+
x<int>();
23+
}
24+
25+
//--- module.modulemap
26+
module hoge {
27+
header "hoge.h"
28+
}
29+
30+
module shared_ptr2 {
31+
header "shared_ptr2.h"
32+
}
33+
34+
//--- main.cpp
635
#include "hoge.h"
736

837
int main() {

0 commit comments

Comments
 (0)