Skip to content

Behaviour of quotation marks in C++-style when running clang cpp with -traditional-cpp #142327

Open
@myzhang1029

Description

@myzhang1029

Using the -traditional-cpp flag (or invoking as cpp directly), clang seems to be mis-parsing quotation marks inside C++-style comments.

Test code:

// Test "double
// Try 'single

Command:

$CC -traditional-cpp -E test.c | cat

(piping through cat to separate stderr from stdout)

Output from clang (Homebrew clang version 20.1.6)
(omitting line number directives)

test.c:1:9: warning: missing terminating '"' character [-Winvalid-pp-token]
    1 | // Test "double
      |         ^
test.c:2:8: warning: missing terminating ' character [-Winvalid-pp-token]
    2 | // Try 'single
      |        ^
2 warnings generated.

// Test "double
// Try 'single

The invalid-pp-token warning seems to be bogus.

Output from GCC (clean output)

// Test "double
// Try 'single

Honestly, since this seems to be a small issue, I am personally fine with this becoming a wont fix or a FIXME inside test/Preprocessor/traditional-cpp.c.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"diverges-from:gccDoes the clang frontend diverge from gcc on this issue

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions