Bug 30549 - compiler warning in resolve.c: possibly uninitialized use of name
Summary: compiler warning in resolve.c: possibly uninitialized use of name
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 30510
  Show dependency treegraph
 
Reported: 2007-01-22 22:11 UTC by Tobias Burnus
Modified: 2007-01-23 16:26 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-01-22 22:11:32 UTC
The compiler warns that in the function "resolve_function" of resolve.c:, the variable "name" might be used unintialized. I think gcc is right.

Name is initialized with:
  if (!pure_function (expr, &name) && name)

and later used without extra if(name) in:

  if (expr->value.function.esym && !expr->value.function.esym->attr.recursive)
    {
      gfc_symbol *esym, *proc;
      esym = expr->value.function.esym;
      proc = gfc_current_ns->proc_name;
      if (esym == proc)
      {
        gfc_error ("Function '%s' at %L cannot call itself, as it is not "
                   "RECURSIVE", name, &expr->where);
        t = FAILURE;
      }

      if (esym->attr.entry && esym->ns->entries && proc->ns->entries
          && esym->ns->entries->sym == proc->ns->entries->sym)
      {
        gfc_error ("Call to ENTRY '%s' at %L is recursive, but function "
                   "'%s' is not declared as RECURSIVE",
                   esym->name, &expr->where, esym->ns->entries->sym->name);
        t = FAILURE;
      }
    }
Comment 1 Andrew Pinski 2007-01-22 22:14:57 UTC
Can you try after:
http://gcc.gnu.org/ml/gcc-cvs/2007-01/msg00765.html
?

>and later used without extra if(name) in:
No, that means it is used possiable as null.

You need to check inside pure_function to see if there is a way that the second argument does not get initialized.
Comment 2 Tobias Burnus 2007-01-22 22:25:03 UTC
> No, that means it is used possiable as null.
> You need to check inside pure_function to see if there is a way that the 
> second argument does not get initialized.

There is:
  if (e->symtree != NULL
        && e->symtree->n.sym != NULL
        && e->symtree->n.sym->attr.proc == PROC_ST_FUNCTION)
    return 1;

One could thus either add a line in pure_function or in "resolve_function" to set name to null. Or in both. Having it in "resolve_function" means we get rid of this warning.
Comment 3 Paul Thomas 2007-01-23 06:26:14 UTC
(In reply to comment #2)
> > No, that means it is used possiable as null.
> > You need to check inside pure_function to see if there is a way that the 
> > second argument does not get initialized.
> 
> There is:
>   if (e->symtree != NULL
>         && e->symtree->n.sym != NULL
>         && e->symtree->n.sym->attr.proc == PROC_ST_FUNCTION)
>     return 1;
> 
> One could thus either add a line in pure_function or in "resolve_function" to
> set name to null. Or in both. Having it in "resolve_function" means we get rid
> of this warning.
> 

No, it must be


  if (e->symtree != NULL
        && e->symtree->n.sym != NULL
        && e->symtree->n.sym->attr.proc == PROC_ST_FUNCTION)
    {
      *name = e->symtree->n.sym->name;
      return 1;
    }
for consistency.

Paul

PS That was my doing, so will fix as obvious.
Comment 4 Paul Thomas 2007-01-23 07:19:39 UTC
Subject: Bug 30549

Author: pault
Date: Tue Jan 23 07:19:26 2007
New Revision: 121080

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121080
Log:
2007-01-23  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/30549
	* resolve.c (pure_function): Add return of name for state-
	ment functions..


Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/resolve.c

Comment 5 Dirk Mueller 2007-01-23 16:26:45 UTC
fortran seems to bootstrap now.