aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schulze Frielinghaus <stefansf@linux.ibm.com>2020-04-26 09:42:29 +0200
committerStefan Schulze Frielinghaus <stefansf@linux.ibm.com>2020-05-05 17:33:54 +0200
commitb776bdca9322977cbb8aced2fe24ecd317a6f16b (patch)
tree0ca1fc14a18702374de4aeb9f6fb4cf4a890afbe
parent733195e367d84914cf9a35c5c78901c973f4159a (diff)
downloadgcc-b776bdca9322977cbb8aced2fe24ecd317a6f16b.zip
gcc-b776bdca9322977cbb8aced2fe24ecd317a6f16b.tar.gz
gcc-b776bdca9322977cbb8aced2fe24ecd317a6f16b.tar.bz2
c-attribs.c: Fix warning about use of uninitialized variable nunits
In function handle_vector_size_attribute local variable nunits is supposed to be initialized by function type_valid_for_vector_size. However, in case ARGS is null the function may return with a non-null value and leave nunits uninitialized. This results in warning/error: gcc/poly-int.h: In function 'tree_node* handle_vector_size_attribute(tree_node**, tree, tree, int, bool*)': gcc/poly-int.h:330:3: error: 'nunits' may be used uninitialized in this function [-Werror=maybe-uninitialized] 330 | ((void) (&(RES).coeffs[0] == (C *) 0), \ | ^ gcc/c-family/c-attribs.c:3695:26: note: 'nunits' was declared here 3695 | unsigned HOST_WIDE_INT nunits; | Added attribute nonnull for argument args in order to silence warning and added an assert statement in order to check the invariant candidate. gcc/c-family/ChangeLog: 2020-05-05 Stefan Schulze Frielinghaus <stefansf@linux.ibm.com> * c-attribs.c (handle_vector_size_attribute): Add attribute nonnull for argument args in order to silence warning of uninitialized variable usage. Since this is local to the compilation unit and thus cannot be checked at call sides by the compiler, added an assert statement in order to verify this.
-rw-r--r--gcc/c-family/ChangeLog8
-rw-r--r--gcc/c-family/c-attribs.c4
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 69ea1fd..fe6cfe7 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-05 Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
+
+ * c-attribs.c (handle_vector_size_attribute): Add attribute
+ nonnull for argument args in order to silence warning of
+ uninitialized variable usage. Since this is local to the
+ compilation unit and thus cannot be checked at call sides by the
+ compiler, added an assert statement in order to verify this.
+
2020-05-01 H.J. Lu <hongjiu.lu@intel.com>
PR target/93492
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index a101312..7a6fb9a 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -117,7 +117,7 @@ static tree handle_tm_attribute (tree *, tree, tree, int, bool *);
static tree handle_tm_wrap_attribute (tree *, tree, tree, int, bool *);
static tree handle_novops_attribute (tree *, tree, tree, int, bool *);
static tree handle_vector_size_attribute (tree *, tree, tree, int,
- bool *);
+ bool *) ATTRIBUTE_NONNULL(3);
static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
static tree handle_nonstring_attribute (tree *, tree, tree, int, bool *);
static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *);
@@ -3697,6 +3697,8 @@ handle_vector_size_attribute (tree *node, tree name, tree args,
if (!type)
return NULL_TREE;
+ gcc_checking_assert (args != NULL);
+
tree new_type = build_vector_type (type, nunits);
/* Build back pointers if needed. */