Skip to content

Commit fb21343

Browse files
committed
[C++20] [Modules] Don't skip pragma diagnostic mappings
Close #75057 Previously, I thought the diagnostic mappings is not meaningful with modules incorrectly. And this problem get revealed by another change recently. So this patch tried to rever the previous "optimization" partially.
1 parent 6e83058 commit fb21343

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

clang/lib/Serialization/GeneratePCH.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ void CXX20ModulesGenerator::HandleTranslationUnit(ASTContext &Ctx) {
114114
getPreprocessor().getHeaderSearchInfo().getHeaderSearchOpts();
115115
HSOpts.ModulesSkipDiagnosticOptions = true;
116116
HSOpts.ModulesSkipHeaderSearchPaths = true;
117-
HSOpts.ModulesSkipPragmaDiagnosticMappings = true;
118117

119118
PCHGenerator::HandleTranslationUnit(Ctx);
120119

clang/test/Modules/pr75057.cppm

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// RUN: rm -rf %t
2+
// RUN: mkdir -p %t
3+
// RUN: split-file %s %t
4+
//
5+
// Treat the behavior of using headers as baseline.
6+
// RUN: %clang_cc1 -std=c++20 %t/use-header.cc -isystem %t -fsyntax-only -verify
7+
//
8+
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -isystem %t -emit-module-interface -o %t/a.pcm
9+
// RUN: %clang_cc1 -std=c++20 %t/use-module.cc -isystem %t -fmodule-file=a=%t/a.pcm -fsyntax-only -verify
10+
11+
//--- sys.h
12+
#ifndef SYS_H
13+
#define SYS_H
14+
15+
#pragma GCC system_header
16+
17+
template <class C>
18+
struct [[deprecated]] iterator {};
19+
20+
_Pragma("GCC diagnostic push")
21+
_Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
22+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
23+
24+
template <class C>
25+
struct reverse_iterator
26+
: public iterator<C> {};
27+
28+
_Pragma("GCC diagnostic pop")
29+
30+
template <class T>
31+
class C {
32+
public:
33+
void i() {
34+
reverse_iterator<T> i;
35+
}
36+
};
37+
38+
#endif
39+
40+
//--- use-header.cc
41+
// expected-no-diagnostics
42+
// However, we see unexpected warnings
43+
#include <sys.h>
44+
45+
void use() {
46+
C<int>().i();
47+
}
48+
49+
//--- a.cppm
50+
module;
51+
#include <sys.h>
52+
export module a;
53+
export using ::iterator;
54+
export using ::C;
55+
56+
//--- use-module.cc
57+
// expected-no-diagnostics
58+
import a;
59+
60+
void use() {
61+
C<int>().i();
62+
}

0 commit comments

Comments
 (0)