File tree Expand file tree Collapse file tree 4 files changed +46
-2
lines changed
Expand file tree Collapse file tree 4 files changed +46
-2
lines changed Original file line number Diff line number Diff line change 330330| P1306R5: [ コンパイル時のタプルやリストを展開処理する` template for ` 文] ( /lang/cpp26/expansion_statements.md.nolink ) | クラス・タプル・Range・パラメータパックなどを展開してすべての要素をコンパイル時の処理する` template for ` 文を追加 | 16 | | | |
331331| P3533R2: [ ` constexpr ` 仮想継承を許可] ( /lang/cpp26/constexpr_virtual_inheritance.md.nolink ) | 定数式の文脈での仮想継承を許可 | 16 | | | |
332332| P2843R3: [ プリプロセッサ仕様での「未定義動作」を不適格 (診断不要) に変更] ( /lang/cpp26/preprocessing_is_never_undefined.md.nolink ) | プリプロセッサとレキサーの文脈での「未定義動作」用語を不適格 (診断不要) に変更 | 16 | | | |
333- | P3868R1: [ モジュール宣言より前での` #line ` ディレクティブの使用を許可する] ( /lang/cpp26/allow_line_before_module_declarations.md.nolink ) | モジュール宣言より前での` #line ` ディレクティブの使用を禁止していたのは過度な制限だった | | | | |
333+ | P3868R1: [ モジュール宣言より前での` #line ` ディレクティブの使用を許可する] ( /lang/cpp26/allow_line_before_module_declarations.md ) | モジュール宣言より前での` #line ` ディレクティブの使用を禁止していたのは過度な制限だった | | | | |
334334
335335
336336各処理系のC++26実装状況ページ:
Original file line number Diff line number Diff line change @@ -494,6 +494,7 @@ int main() {
494494- [ C++23 無意味なexport宣言を禁止する] ( /lang/cpp23/meaningful_exports.md )
495495- [ C++26 モジュール宣言でのモジュール名のマクロ展開を禁止する] ( /lang/cpp26/module_declarations_shouldnt_be_macros.md )
496496- [ C++26 ` main ` 関数をグローバルモジュールに関連付けることを許可] ( /lang/cpp26/allow_attaching_main_to_the_global_module.md )
497+ - [ C++26 モジュール宣言より前での` #line ` ディレクティブの使用を許可する] ( /lang/cpp26/allow_line_before_module_declarations.md )
497498
498499
499500## 参照
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ C++26とは、2026年中に改訂される予定の、C++バージョンの通
105105| ----------| ------|
106106| [ モジュール宣言でのモジュール名のマクロ展開を禁止する] ( /lang/cpp26/module_declarations_shouldnt_be_macros.md ) | ` export module MACRO_NAME; ` を禁止 |
107107| [ ` main ` 関数をグローバルモジュールに含められるようにする] ( /lang/cpp26/allow_attaching_main_to_the_global_module.md ) | ` main ` 関数に` extern "C++" ` を指定できるようにすることで名前付きモジュールに含められるようにする |
108- | [ モジュール宣言より前での` #line ` ディレクティブの使用を許可する] ( /lang/cpp26/allow_line_before_module_declarations.md.nolink ) | モジュール宣言より前での` #line ` ディレクティブの使用を禁止していたのは過度な制限だった |
108+ | [ モジュール宣言より前での` #line ` ディレクティブの使用を許可する] ( /lang/cpp26/allow_line_before_module_declarations.md ) | モジュール宣言より前での` #line ` ディレクティブの使用を禁止していたのは過度な制限だった |
109109
110110
111111### 機能の非推奨化
Original file line number Diff line number Diff line change 1+ # モジュール宣言より前での` #line ` ディレクティブの使用を許可する [ P3868R1]
2+ * cpp26[ meta cpp]
3+
4+ <!-- start lang caution -->
5+
6+ このページはC++26に採用される見込みの言語機能の変更を解説しています。
7+
8+ のちのC++規格でさらに変更される場合があるため[ 関連項目] ( #relative-page ) を参照してください。
9+
10+ <!-- last lang caution -->
11+
12+ ## 概要
13+ C++20でモジュールが導入された際、グローバルモジュールフラグメントより前でのプリプロセッサ制御行がP1857R3によって禁止された。この制限により` #line ` ディレクティブもモジュール宣言より前に書くことができなくなっていた。
14+
15+ C++26では、` #line ` ディレクティブをモジュール宣言より前に記述することが許可される。
16+
17+ ``` cpp
18+ #line 1 "A.cppm"
19+ export module a; // C++26: OK (C++20/23: ill-formed)
20+ ```
21+
22+
23+ ## 仕様
24+ モジュールファイルの文法に` #line ` ディレクティブの出現を許可するよう変更される。具体的には、グローバルモジュールフラグメントの有無にかかわらず、モジュール宣言より前に` #line ` ディレクティブを記述できる。
25+
26+
27+ ## この機能が必要になった背景・経緯
28+ build2、ccache、distccなどのビルドツールは、前処理済みの出力をコンパイラに再入力することに依存しており、その出力には通常` #line ` ディレクティブが含まれている。しかし、モジュール宣言より前での制御行が禁止されていたため、以下のような前処理済み出力がコンパイルできなかった。
29+
30+ ``` cpp
31+ #line 1 "A.cppm"
32+ export module a;
33+ ```
34+
35+ この制限は過度であり、` #line ` ディレクティブはコードの意味に影響を与えないため、禁止する理由がなかった。
36+
37+
38+ ## <a id =" relative-page " href =" #relative-page " >関連項目</a >
39+ - [ C++20 モジュール] ( /lang/cpp20/modules.md )
40+
41+
42+ ## 参照
43+ - [ P3868R1 Allow #line before module declarations] ( https://open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3868r1.html )
You can’t perform that action at this time.
0 commit comments