This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/15052] gcc frontend accepts mismatched function declaration/defintion


------- Additional Comments From tjruwase at stanfordalumni dot org  2004-04-22 00:00 -------
Is this consistent considering that the front end rejects the following 

int const foo();
int foo();

In addition, despite the warning message of the qualifier being ignored, the
return type is still augmented with the qualifier by the line 
  type = c_build_qualified_type (type, type_quals);
 which comes right after the warning in the excerpt of c-decl.c below
I m not sure what the right thing is, but this seems inconsistent to me.

 if (type_quals)
	    {
	      /* Type qualifiers on a function return type are normally
		 permitted by the standard but have no effect, so give a
		 warning at -W.  Qualifiers on a void return type have
		 meaning as a GNU extension, and are banned on function
		 definitions in ISO C.  FIXME: strictly we shouldn't
		 pedwarn for qualified void return types except on function
		 definitions, but not doing so could lead to the undesirable
		 state of a "volatile void" function return type not being
		 warned about, and a use of the function being compiled
		 with GNU semantics, with no diagnostics under -pedantic.  */
	      if (VOID_TYPE_P (type) && pedantic && !in_system_header)
		pedwarn ("ISO C forbids qualified void function return type");
	      else if (extra_warnings
		       && !(VOID_TYPE_P (type)
			    && type_quals == TYPE_QUAL_VOLATILE))
		warning ("type qualifiers ignored on function return type");

	      type = c_build_qualified_type (type, type_quals);
	    } 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15052


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]