<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/153673>153673</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang error expected unqualified-id in comment when switching on comment parsing
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
renebarto
</td>
</tr>
</table>
<pre>
I'm using the following header file to parse:
#pragma once
// My namespace
namespace X {
namespace Y {
class A
{
public:
A() = default;
virtual ~A() = default;
virtual void foo() const;
};
} // namespace Y
} // namespace X
I Include this header in a cpp file:
#include "A.h"
int main(int argc, char **argv)
{
X::Y::A a;
a.foo();
return 0;
}
Of course the class has an implementation:
#include "A.h"
#include <iostream>
using namespace X;
using namespace Y;
void A::foo() const
{
std::cout << "A::foo()" << std::endl;
}
This set is a simple set to try playing with the AST parser.
When running the parser and switching on comment parsing:
clang::Preprocessor &preProcessor = compilerInstance.getPreprocessor();
preProcessor.SetCommentRetentionState(true, true);
I'm getting errors on the commented lines:
Caught exception: Parsing failed due to: [Error] "code/applications/simpleMain/include/A.h":16: expected unqualified-id
[Error] "code/applications/simpleMain/include/A.h":3: expected unqualified-id
[Error] "code/applications/simpleMain/include/A.h":15: expected unqualified-id
[Error] "code/applications/simpleMain/include/A.h":16: expected unqualified-id
I have no idea why clang would generate errors in this case. It may be that I'm doing something wrong, but this seems incorrect.
When I change one of the comment lines to use three forward slashes instead of two, I do get a comment callback, but still the same errors.
I'm using llvm 20.0.0git
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VsGO2zYQ_Rr6Moggk-v1-qCDdjcGfAgaNAGaHEfkWGJLkSpJreNLv70gKXudBdL2UAQwIIpDzsx782YsDEH3lqhhm0e2eV7hHAfnG0-WOvTRrTqnzs2B8e0Ic9C2hzgQHJ0x7pTeBkJFHo7aEEQHE_pATLSszj8uJo_9iOCspMvenvE9fDiDxZH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