[clang][Interp] Handle AttributedStmts (#66495)

Just ignore the attributes.
This commit is contained in:
Timm Baeder 2023-09-15 21:03:18 +02:00 committed by GitHub
parent d2e787d5d7
commit d462bd527a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -243,6 +243,8 @@ bool ByteCodeStmtGen<Emitter>::visitStmt(const Stmt *S) {
case Stmt::GCCAsmStmtClass:
case Stmt::MSAsmStmtClass:
return visitAsmStmt(cast<AsmStmt>(S));
case Stmt::AttributedStmtClass:
return visitAttributedStmt(cast<AttributedStmt>(S));
case Stmt::NullStmtClass:
return true;
default: {
@ -625,6 +627,12 @@ bool ByteCodeStmtGen<Emitter>::visitAsmStmt(const AsmStmt *S) {
return this->emitInvalid(S);
}
template <class Emitter>
bool ByteCodeStmtGen<Emitter>::visitAttributedStmt(const AttributedStmt *S) {
// Ignore all attributes.
return this->visitStmt(S->getSubStmt());
}
namespace clang {
namespace interp {

View File

@ -64,6 +64,7 @@ private:
bool visitCaseStmt(const CaseStmt *S);
bool visitDefaultStmt(const DefaultStmt *S);
bool visitAsmStmt(const AsmStmt *S);
bool visitAttributedStmt(const AttributedStmt *S);
bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);

View File

@ -43,4 +43,11 @@ namespace InitDecl {
return false;
}
static_assert(!f2(), "");
constexpr int attrs() {
if (1) [[likely]] {}
return 1;
}
static_assert(attrs() == 1, "");
};