From df66f73df10a7483cd94d22a9af1319d61076224 Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Sun, 9 Nov 2025 20:46:24 +0100 Subject: [PATCH 1/2] P3868R1 Allow #line before module declarations Fixes NB US 55-102 (C++26 CD). - Retained position of #line alternative within control-line. --- source/preprocessor.tex | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 43b2c6a484..e0e9d5b95a 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -18,7 +18,7 @@ \begin{bnf} \nontermdef{module-file}\br - \opt{pp-global-module-fragment} pp-module \opt{group} \opt{pp-private-module-fragment} + \opt{line-directives} \opt{pp-global-module-fragment} pp-module \opt{group} \opt{pp-private-module-fragment} \end{bnf} \begin{bnf} @@ -55,13 +55,18 @@ \terminal{\# define } identifier lparen \terminal{... )} replacement-list new-line\br \terminal{\# define } identifier lparen identifier-list \terminal{, ... )} replacement-list new-line\br \terminal{\# undef \ } identifier new-line\br - \terminal{\# line \ \ } pp-tokens new-line\br + line-directive\br \terminal{\# error \ } \opt{pp-tokens} new-line\br \terminal{\# warning} \opt{pp-tokens} new-line\br \terminal{\# pragma } \opt{pp-tokens} new-line\br \terminal{\# }new-line \end{bnf} +\begin{bnf} +\nontermdef{line-directives}\br + line-directive \opt{line-directives} +\end{bnf} + \begin{bnf} \nontermdef{if-section}\br if-group \opt{elif-groups} \opt{else-group} endif-line @@ -2070,6 +2075,11 @@ \indextext{preprocessing directive!line control}% \indextext{\idxcode{\#line}|see{preprocessing directive, line control}} +\begin{bnf} +\nontermdef{line-directive}\br + \terminal{\# line} pp-tokens new-line\br +\end{bnf} + \pnum The \grammarterm{string-literal} of a \tcode{\#line} From cd2d1ee7d89912b955f3f1895bc038de1b88f2ce Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Tue, 11 Nov 2025 20:23:30 +0100 Subject: [PATCH 2/2] fixup: grammar for line-directive --- source/preprocessor.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/preprocessor.tex b/source/preprocessor.tex index e0e9d5b95a..140a59f0ef 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -2077,7 +2077,7 @@ \begin{bnf} \nontermdef{line-directive}\br - \terminal{\# line} pp-tokens new-line\br + \terminal{\# line} pp-tokens new-line \end{bnf} \pnum