Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-scan-deps: macro is not handled correctly #92357

Open
RichardLuo0 opened this issue May 16, 2024 · 1 comment
Open

clang-scan-deps: macro is not handled correctly #92357

RichardLuo0 opened this issue May 16, 2024 · 1 comment

Comments

@RichardLuo0
Copy link

#define STD import std;
STD;

int main() {
    std::cout << 1 <<std::endl;
}

This file will compile, but clang-scan-deps gives:

{
  "revision": 0,
  "rules": [
    {
      "primary-output": "test"
    }
  ],
  "version": 1
}

The command is clang-scan-deps.exe -format=p1689 -- clang++.exe -fansi-escape-codes -fcolor-diagnostics -c -march=native -std=c++20 -Wall main.cpp -o test

But if I change to

#define STD std;
import STD;

int main() {
    std::cout << 1 <<std::endl;
}

Now it gives the correct output.

@adalisk-emikhaylov
Copy link

If I'm reading http://eel.is/c++draft/lex.pptoken#4 correctly, the first snippet is illegal. import is a preprocessor directive, not unlike #include an others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants