[PATCH] D37254: [Sema] Disallow assigning record lvalues with nested const-qualified fields.

Bevin Hansson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 29 01:40:50 PDT 2017


bevinh created this revision.

According to C99 6.3.2.1p1, structs and unions with nested
const-qualified fields (that is, const-qualified fields
declared at some recursive level of the aggregate) are not
modifiable lvalues. However, Clang permits assignments of
these lvalues.

With this patch, we both prohibit the assignment of records
with const-qualified fields and emit a best-effort diagnostic.
This fixes https://bugs.llvm.org/show_bug.cgi?id=31796 .


https://reviews.llvm.org/D37254

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ExprClassification.cpp
  lib/AST/Type.cpp
  lib/Sema/SemaExpr.cpp
  test/Sema/assign.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37254.113038.patch
Type: text/x-patch
Size: 10176 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170829/0a217fcd/attachment-0001.bin>


More information about the cfe-commits mailing list