Skip to content

Commit

Permalink
Disallow splicing of unnamed bit-fields.
Browse files Browse the repository at this point in the history
Closes issue llvm#76.
  • Loading branch information
katzdm committed Jul 17, 2024
1 parent 783e2a6 commit a27d47b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -3132,6 +3132,8 @@ def err_splice_global_scope_as_namespace : Error<
def err_member_access_splice_not_class_member : Error<
"use of splice as qualified member access requires the reflection to be a "
"member of a class">;
def err_splice_unnamed_bit_field : Error<
"cannot splice a reflection of an unnamed bit-field">;
def err_unsupported_splice_kind : Error<
"splicing %0 %select{as template arguments is|is}1 %select{not|not yet}2 "
"%select{supported|implemented}2">;
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Sema/SemaReflect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,12 @@ ExprResult Sema::BuildReflectionSpliceExpr(
return ExprError();
}

if (auto *FD = dyn_cast<FieldDecl>(TheDecl);
FD && FD->isUnnamedBitField()) {
Diag(Operand->getExprLoc(), diag::err_splice_unnamed_bit_field);
return ExprError();
}

// Create a new DeclRefExpr, since the operand of the reflect expression
// was parsed in an unevaluated context (but a splice expression is not
// necessarily, and frequently not, in such a context).
Expand Down

0 comments on commit a27d47b

Please sign in to comment.