From 2c473cc8744fc5b2077349add2283826061ce881 Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Sun, 9 Nov 2025 20:46:24 +0100 Subject: [PATCH] P3868R1 Allow #line before module declarations Fixes NB US 55-102 (C++26 CD). Editorial note: * 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 487c036093..e449e8308c 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 @@ -2062,6 +2067,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 +\end{bnf} + \pnum The \grammarterm{string-literal} of a \tcode{\#line}