]> granicus.if.org Git - clang/commit
[Sema] Disallow assigning record lvalues with nested const-qualified fields.
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Tue, 19 Sep 2017 13:10:30 +0000 (13:10 +0000)
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Tue, 19 Sep 2017 13:10:30 +0000 (13:10 +0000)
commit9411957410813aeefc1bb299abcb856ce1ef8aae
tree742ded633baafde8bd4cea48556a373b4c69c34d
parentd304062b8cf0086ef8a3a9b2dad8e41e037f66a5
[Sema] Disallow assigning record lvalues with nested const-qualified fields.

Summary:
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 .

Committing on behalf of bevinh (Bevin Hansson).

Reviewers: rtrieu, rsmith, bjope

Reviewed By: bjope

Subscribers: Ka-Ka, rogfer01, bjope, fhahn, cfe-commits

Differential Revision: https://reviews.llvm.org/D37254

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313628 91177308-0d34-0410-b5e6-96231b3b80d8
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