aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Uecker <muecker@gwdg.de>2020-12-16 23:47:52 +0100
committerMartin Uecker <muecker@gwdg.de>2020-12-16 23:51:25 +0100
commit58a45ce44a9acf3d15fada265d2a391a8e1bc960 (patch)
tree69fbd5b87d917a812ff0d60a679afcf7d34d8d34 /gcc
parentec13758ed41936bf803640f0dd8c259c034fe4b9 (diff)
downloadgcc-58a45ce44a9acf3d15fada265d2a391a8e1bc960.zip
gcc-58a45ce44a9acf3d15fada265d2a391a8e1bc960.tar.gz
gcc-58a45ce44a9acf3d15fada265d2a391a8e1bc960.tar.bz2
C: Drop qualifiers of assignment expressions. [PR98047]
ISO C17 6.5.15.1 specifies that the result is the type the LHS would have after lvalue conversion. 2020-12-16 Martin Uecker <muecker@gwdg.de> gcc/c/ PR c/98047 * c-typeck.c (build_modify_expr): Drop qualifiers. gcc/testsuite/ PR c/98047 * gcc.dg/qual-assign-7.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c/c-typeck.c13
-rw-r--r--gcc/testsuite/gcc.dg/qual-assign-7.c18
2 files changed, 21 insertions, 10 deletions
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 7d58e8d..f68cb01 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -6275,16 +6275,9 @@ build_modify_expr (location_t location, tree lhs, tree lhs_origtype,
"enum conversion in assignment is invalid in C++");
}
- /* If the lhs is atomic, remove that qualifier. */
- if (is_atomic_op)
- {
- lhstype = build_qualified_type (lhstype,
- (TYPE_QUALS (lhstype)
- & ~TYPE_QUAL_ATOMIC));
- olhstype = build_qualified_type (olhstype,
- (TYPE_QUALS (lhstype)
- & ~TYPE_QUAL_ATOMIC));
- }
+ /* Remove qualifiers. */
+ lhstype = build_qualified_type (lhstype, TYPE_UNQUALIFIED);
+ olhstype = build_qualified_type (olhstype, TYPE_UNQUALIFIED);
/* Convert new value to destination type. Fold it first, then
restore any excess precision information, for the sake of
diff --git a/gcc/testsuite/gcc.dg/qual-assign-7.c b/gcc/testsuite/gcc.dg/qual-assign-7.c
new file mode 100644
index 0000000..3e064e8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/qual-assign-7.c
@@ -0,0 +1,18 @@
+/* test that assignment drops qualifiers, Bug 98047 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+
+volatile int jv;
+extern int j;
+extern typeof(jv = 1) j;
+
+_Atomic int ja;
+extern typeof(ja = 1) j;
+
+int * __restrict pa;
+extern int *p;
+extern typeof(pa = 0) p;
+
+
+