From 55d57c84bbbc4b39f439d2ab99e9d7aa282bcc9d Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 13 Dec 2017 14:40:48 -0500 Subject: [PATCH 23/25] {[15/14], approved} v3: Use fold_for_warn in get_atomic_generic_size Changed in v3: * reordered warning and error Changed in v2: * check for error_mark_node before calling fold_for_warn. Blurb from v1: This is needed, otherwise g++'s c-c++-common/pr83059.c fails to emit the "invalid memory model argument 6" warning. gcc/c-family/ChangeLog: * c-common.c (get_atomic_generic_size): Perform the test for integral type before the range test for any integer constant, fixing indentation of braces. Call fold_for_warn before testing for an INTEGER_CST. --- gcc/c-family/c-common.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 3438b87..7cc749b 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -6721,8 +6721,15 @@ get_atomic_generic_size (location_t loc, tree function, for (x = n_param - n_model ; x < n_param; x++) { tree p = (*params)[x]; + if (!INTEGRAL_TYPE_P (TREE_TYPE (p))) + { + error_at (loc, "non-integer memory model argument %d of %qE", x + 1, + function); + return 0; + } + p = fold_for_warn (p); if (TREE_CODE (p) == INTEGER_CST) - { + { /* memmodel_base masks the low 16 bits, thus ignore any bits above it by using TREE_INT_CST_LOW instead of tree_to_*hwi. Those high bits will be checked later during expansion in target specific @@ -6732,14 +6739,7 @@ get_atomic_generic_size (location_t loc, tree function, "invalid memory model argument %d of %qE", x + 1, function); } - else - if (!INTEGRAL_TYPE_P (TREE_TYPE (p))) - { - error_at (loc, "non-integer memory model argument %d of %qE", x + 1, - function); - return 0; - } - } + } return size_0; } -- 1.8.5.3