aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorMartin Uecker <muecker@gwdg.de>2020-12-07 23:51:25 +0100
committerMartin Uecker <muecker@gwdg.de>2020-12-07 23:57:43 +0100
commita19a242c708060e067b4fd5a76995144e6f239d0 (patch)
tree2656bc2992da8a4b9aba84a5ea09b35818e51f3b /gcc/c
parentb737b70fad398728f6006e8397d1bb31ccea4ce7 (diff)
downloadgcc-a19a242c708060e067b4fd5a76995144e6f239d0.zip
gcc-a19a242c708060e067b4fd5a76995144e6f239d0.tar.gz
gcc-a19a242c708060e067b4fd5a76995144e6f239d0.tar.bz2
C: Fix atomic loads. [PR97981]
To handle atomic loads correctly, we need to move the code that drops qualifiers in lvalue conversion after the code that handles atomics. 2020-12-07 Martin Uecker <muecker@gwdg.de> gcc/c/ PR c/97981 * c-typeck.c (convert_lvalue_to_rvalue): Move the code that drops qualifiers to the end of the function. gcc/testsuite/ PR c/97981 * gcc.dg/pr97981.c: New test. * gcc.dg/pr60195.c: Adapt test.
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/c-typeck.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index cdc491a..138af07 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -2080,9 +2080,6 @@ convert_lvalue_to_rvalue (location_t loc, struct c_expr exp,
exp = default_function_array_conversion (loc, exp);
if (!VOID_TYPE_P (TREE_TYPE (exp.value)))
exp.value = require_complete_type (loc, exp.value);
- if (convert_p && !error_operand_p (exp.value)
- && (TREE_CODE (TREE_TYPE (exp.value)) != ARRAY_TYPE))
- exp.value = convert (build_qualified_type (TREE_TYPE (exp.value), TYPE_UNQUALIFIED), exp.value);
if (really_atomic_lvalue (exp.value))
{
vec<tree, va_gc> *params;
@@ -2119,6 +2116,9 @@ convert_lvalue_to_rvalue (location_t loc, struct c_expr exp,
exp.value = build4 (TARGET_EXPR, nonatomic_type, tmp, func_call,
NULL_TREE, NULL_TREE);
}
+ if (convert_p && !error_operand_p (exp.value)
+ && (TREE_CODE (TREE_TYPE (exp.value)) != ARRAY_TYPE))
+ exp.value = convert (build_qualified_type (TREE_TYPE (exp.value), TYPE_UNQUALIFIED), exp.value);
return exp;
}