Closed berolinux closed 10 months ago
@llvm/issue-subscribers-clang-frontend
Author: Bernhard Rosenkraenzer (berolinux)
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
1) In the comments of the issue, request for it to be assigned to you.
2) Fix the issue locally.
3) Run the test suite locally.
3.1) Remember that the subdirectories under test/
create fine-grained testing targets, so you can
e.g. use make check-clang-ast
to only run Clang's AST tests.
4) Create a Git commit.
5) Run git clang-format HEAD~1
to format your changes.
6) Open a pull request to the upstream repository on GitHub.
6.1) Detailed instructions can be found here.
If you have any further questions about this issue, don't hesitate to ask via a comment on this Github issue.
@llvm/issue-subscribers-good-first-issue
Author: Bernhard Rosenkraenzer (berolinux)
Hi. I want to help fix this bug. Can someone assign this issue to me? Thanks.
@Lancern I hope it is ok for you that I created this pull request, but since the issue is open for more than two weeks I assumed that you are busy in other projects at the moment.
Hi,
I fixed this bug (my first fix for llvm, any suggestions of how to improve my process are welcome).
Line 2705 in ParseDeclCXX.cpp calls TryAnnotateCXXScopeToken() without guarding whether C or C++ is being compiled. Line 3486 in ParseDecl.cpp has the same issue.
A test file "test.c" which contains only the double colon "::" now yields this error message instead of the exception before.
test.c:1:1: error: expected identifier or '(' 1 | :: | ^ 1 error generated.
Clang (not clang++) crashes on a file that contains just "::", throwing an assertion that such code should be guarded by checking for C++.
Of course this is not valid C, but I'd expect clang to give a proper error instead of an assertion and a backtrace.
The same thing happens in real world code where, for example, a C application tries to
#include
a header containing C++ constructs, such as