diff options
author | kargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-21 22:48:39 +0000 |
---|---|---|
committer | kargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-21 22:48:39 +0000 |
commit | cada8741cc3d25284c4c239ee4c10fbe556144b9 (patch) | |
tree | 9cb3e25e366ce27408189d086dbe4d0f4fdc9023 /gcc/fortran/check.c | |
parent | 9936b574f3a6c73030b01abf35cb2f9df539482a (diff) | |
download | gcc-cada8741cc3d25284c4c239ee4c10fbe556144b9.tar.gz |
2011-10-20 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/50821
* check.c (gfc_check_ishftc): Check args are constant before
extracting the integer.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180316 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/check.c')
-rw-r--r-- | gcc/fortran/check.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c index 9aaad01ca36..34b3a68057c 100644 --- a/gcc/fortran/check.c +++ b/gcc/fortran/check.c @@ -1967,22 +1967,29 @@ gfc_check_ishftc (gfc_expr *i, gfc_expr *shift, gfc_expr *size) if (less_than_bitsize1 ("I", i, "SIZE", size, true) == FAILURE) return FAILURE; - gfc_extract_int (size, &i3); - if (i3 <= 0) + if (size->expr_type == EXPR_CONSTANT) { - gfc_error ("SIZE at %L must be positive", &size->where); - return FAILURE; - } + gfc_extract_int (size, &i3); + if (i3 <= 0) + { + gfc_error ("SIZE at %L must be positive", &size->where); + return FAILURE; + } - gfc_extract_int (shift, &i2); - if (i2 < 0) - i2 = -i2; + if (shift->expr_type == EXPR_CONSTANT) + { + gfc_extract_int (shift, &i2); + if (i2 < 0) + i2 = -i2; - if (i2 > i3) - { - gfc_error ("The absolute value of SHIFT at %L must be less than " - "or equal to SIZE at %L", &shift->where, &size->where); - return FAILURE; + if (i2 > i3) + { + gfc_error ("The absolute value of SHIFT at %L must be less " + "than or equal to SIZE at %L", &shift->where, + &size->where); + return FAILURE; + } + } } } else if (less_than_bitsize1 ("I", i, NULL, shift, true) == FAILURE) |