Issue 239569
Summary [pch] `-fpch-validate-input-files-content` breaks when using `#pragma once`
Labels new issue
Assignees
Reporter tobil4sk
    Using clang on arch linux:
```console
$ clang --version
clang version 23.1.4
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
```

header.h:
```c
#pragma once

struct MyStruct {};
```
main.c:
```c
#include "header.h"
```

```console
$ clang header.h -o header.h.pch -fpch-validate-input-files-content
$ clang -c main.c -include-pch header.h.pch -fpch-validate-input-files-content # no changes, builds fine
$ touch header.h # change timestamp, but not content
$ clang -c main.c -include-pch header.h.pch -fpch-validate-input-files-content
In file included from main.c:1:
./header.h:3:8: error: redefinition of 'MyStruct'
    3 | struct MyStruct {};
      |        ^
main.c:1:1: note: '/home/USER/test-pch-recompile/header.h' included multiple times, additional include site here
    1 | #include "header.h"
      | ^
main.c:1:10: note: '/home/USER/test-pch-recompile/header.h' included multiple times, additional include site here
    1 | #include "header.h"
      | ^
1 error generated.
```

Replacing `#pragma once` with traditional include guards works around the issue.

This is probably what #232564 was about. It could be a limitation with how #24761 was resolved.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to