Date: Sun, 21 Sep 2025 09:59:51 -0700
Doesn't preprocessing happen before trying to understand the import
statement? Or to rephrase: during which translation phase is the
import statement handled?
On Sun, Sep 21, 2025 at 9:39 AM Yrong via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Hi experts,
>
> I'm working on implement P1857R3 in clang.
>
> Hubert provided an example:
> ```
> typedef int import;
> #define EMP
> EMP import m;
> ```
>
> If we directly compile this code snippet, due to the `import` identifier is not in the start of line, and according to the current wording of the standard, this is not a C++ import directive. But if
> we preprocessing the file first and compile the preprocessing output would have different behavior than above:
> Generated by clang:
> ```
> # 1 "./main.cpp"
> # 1 "<built-in>" 1
> # 1 "<built-in>" 3
> # 490 "<built-in>" 3
> # 1 "<command line>" 1
> # 1 "<built-in>" 2
> # 1 "./main.cpp" 2
> typedef int import;
>
> import m;
> ```
>
> The `import` identifier now at start of line, so it's c++ import directive.
>
> Is this the expected behavior? Should we keep the behavior consistent in both cases?
>
> Best regards,
> Yihan
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
statement? Or to rephrase: during which translation phase is the
import statement handled?
On Sun, Sep 21, 2025 at 9:39 AM Yrong via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Hi experts,
>
> I'm working on implement P1857R3 in clang.
>
> Hubert provided an example:
> ```
> typedef int import;
> #define EMP
> EMP import m;
> ```
>
> If we directly compile this code snippet, due to the `import` identifier is not in the start of line, and according to the current wording of the standard, this is not a C++ import directive. But if
> we preprocessing the file first and compile the preprocessing output would have different behavior than above:
> Generated by clang:
> ```
> # 1 "./main.cpp"
> # 1 "<built-in>" 1
> # 1 "<built-in>" 3
> # 490 "<built-in>" 3
> # 1 "<command line>" 1
> # 1 "<built-in>" 2
> # 1 "./main.cpp" 2
> typedef int import;
>
> import m;
> ```
>
> The `import` identifier now at start of line, so it's c++ import directive.
>
> Is this the expected behavior? Should we keep the behavior consistent in both cases?
>
> Best regards,
> Yihan
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
Received on 2025-09-21 17:00:16