aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/resolve.cc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2023-03-09 18:59:08 +0100
committerHarald Anlauf <anlauf@gmx.de>2023-03-10 18:56:13 +0100
commite20e5d9dc11b64e8eabce6803c91cb5768207083 (patch)
treec5d0aca3ac3cee8d70f6673d3c342e58e3d92818 /gcc/fortran/resolve.cc
parentfcbc5c190c40b51c82f827830ce403c07d628960 (diff)
downloadgcc-e20e5d9dc11b64e8eabce6803c91cb5768207083.zip
gcc-e20e5d9dc11b64e8eabce6803c91cb5768207083.tar.gz
gcc-e20e5d9dc11b64e8eabce6803c91cb5768207083.tar.bz2
Fortran: fix ICE with bind(c) in block data [PR104332]
gcc/fortran/ChangeLog: PR fortran/104332 * resolve.cc (resolve_symbol): Avoid NULL pointer dereference while checking a symbol with the BIND(C) attribute. gcc/testsuite/ChangeLog: PR fortran/104332 * gfortran.dg/bind_c_usage_34.f90: New test.
Diffstat (limited to 'gcc/fortran/resolve.cc')
-rw-r--r--gcc/fortran/resolve.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 2780c82..4658587 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -15933,8 +15933,8 @@ resolve_symbol (gfc_symbol *sym)
/* First, make sure the variable is declared at the
module-level scope (J3/04-007, Section 15.3). */
- if (sym->ns->proc_name->attr.flavor != FL_MODULE &&
- sym->attr.in_common == 0)
+ if (!(sym->ns->proc_name && sym->ns->proc_name->attr.flavor == FL_MODULE)
+ && !sym->attr.in_common)
{
gfc_error ("Variable %qs at %L cannot be BIND(C) because it "
"is neither a COMMON block nor declared at the "