Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[cpp.cond] Keywords are not identifiers while preprocessing#8518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
AlisdairM wants to merge1 commit intocplusplus:main
base:main
Choose a base branch
Loading
fromAlisdairM:keywords_are_not_prepocessing_tokens

Conversation

@AlisdairM
Copy link
Contributor

@AlisdairMAlisdairM commentedNov 14, 2025
edited
Loading

Move seemingly normative reference to keywords in #if expressions into a note.

Comment on lines 564 to 567
\begin{note}
Keywords are identifiers during preprocessing and are not valid macro names,
so are always replaced by\tcode{0} before being converted into a token.
\end{note}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do we need this note after we've removed "keyword" in the first place?

We do mention "true" and "false" as identifiers above, so there is a strong hint that phase 7 keywords are in view here.
If keywords were a separate thing, the note below would need to be amended with "keywords", too, I think.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We mentiontrue as, being an identifier that is not defined as a macro, it should convert to a0 before we turn the preprocessor tokens into tokens in order to evaluate the#if predicate --- we arrange that the only tokens that convert are literals. I think the first note covers that, and the alternative tokens note covers a different matter as alternative tokens are never identifiers. Maybe I am too focused on identifiers as a preprocessing-token that is being converted though?

Copy link
Member

@jensmaurerjensmaurerNov 14, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I was trying to say that your new "note" can go entirely, because "true" is a keyword and is mentioned in the (revised) "identifiers except..." phrasing. That wouldn't be necessary if "true" weren't considered a (preprocessor-level) identifier at that point.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I am happy to remove the note --- should I do so now, or wait for more feedback in case others prefer to add the note? I agree that my preference would be to remove the note as I doubt folks would be genuinely confused.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For comparison, C23 says

... all remaining identifiers other than true (including those lexically identical to keywords such as false) are replaced with the pp-number 0, true is replaced with pp-number 1, and then each preprocessing token is converted into a token.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Of course,true andfalse are essentially integer literals in C, but are boolean literals in C++. By preserving the spelling of the token, we preserve the type in the expression. I do not know how significant that change might be, but if we were to synchronize wording with C it would definitely become a CWG issue due to that type change.

Copy link
Member

@jensmaurerjensmaurerNov 14, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm wondering how you would observe the type change at the preprocessor#if level.

That said, the more important part for this pull request is the parenthetical "(including those lexically identical to keywords)" which re-emphasizes that phase 4 "identifiers" can be spelled like phase 7 keywords. That's another option, instead of the note.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If the note is kept, please leave it at "Keywords are identifiers during preprocessing and are not valid macro names."

@AlisdairMAlisdairMforce-pushed thekeywords_are_not_prepocessing_tokens branch fromd43a454 to1df1072CompareNovember 17, 2025 08:07
Copy link
Contributor

@hubert-reinterpretcasthubert-reinterpretcast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I believe that the exception should be delimited by commas of a parenthetical nature.

\grammarterm{has-attribute-expression}s
have been performed,
all remaining identifiersandkeywords,
all remaining identifiers(including those lexically identical tokeywords)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
all remaining identifiers (including those lexically identical to keywords)
all remaining identifiers (including those lexically identical to keywords),

\tcode{true}
and
\tcode{false},
\tcode{false}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
\tcode{false}
\tcode{false},

@jensmaurerjensmaurer added the changes requestedChanges to the wording or approach have been requested and not yet applied. labelNov 17, 2025
@jensmaurer
Copy link
Member

I think I like the overall outcome here.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@jensmaurerjensmaurerjensmaurer left review comments

+1 more reviewer

@hubert-reinterpretcasthubert-reinterpretcasthubert-reinterpretcast left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

changes requestedChanges to the wording or approach have been requested and not yet applied.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@AlisdairM@jensmaurer@hubert-reinterpretcast

[8]ページ先頭

©2009-2025 Movatter.jp