[cfe-dev] return statements without expressions in non-void functions revisited

Douglas Gregor dgregor at apple.com
Mon Jul 25 14:57:16 PDT 2011



Sent from my iPhone

On Jul 25, 2011, at 2:09 PM, Jack Howarth <howarth at bromo.med.uc.edu> wrote:

> On Mon, Jul 25, 2011 at 12:50:01PM -0700, Douglas Gregor wrote:
>> 
>> On Jul 15, 2011, at 5:56 PM, Jack Howarth wrote:
>> 
>>>  In porting texlive under clang for fink, we have run into the same issue from this thread...
>>> 
>>> http://comments.gmane.org/gmane.comp.compilers.clang.devel/10688
>>> 
>>> In that thread it was suggested that -std=c89 might be modified to convert the error into
>>> a warning for...
>>> 
>>> [MacPro:~] howarth% clang -std=gnu89 -c type1_test.c -fno-strict-aliasing 
>>> type1_test.c:24:8: error: non-void function 'PSFakePop' should return a value [-Wreturn-type]
>>> else Error0("PSFakePop: Stack empty\n");
>>>      ^
>>> type1_test.c:13:54: note: instantiated from:
>>> #define Error0(errmsg) { CC; IfTrace0(TRUE, errmsg); Error;}
>>>                                                    ^
>>> type1_test.c:11:32: note: instantiated from:
>>> #define Error {errflag = TRUE; return;}
>>>                              ^
>>> 1 error generated.
>>> 
>>> This appears to never have been implemented however. Any suggestions on the best approach to
>>> revise the following testcase to avoid the error under clang (which I also see under icc
>>> but not gcc trunk even with -std=c90)?
>> 
>> The flag -Wno-error=return-type will downgrade this error to a warning. -Wno-return-type will turn off the warning/error entirely.
>> 
>>    - Doug
> 
> Doug,
>   Is there any documentation of the full set of warnings which are treated
> as errors that can be suppressed with -Wno-error in this manner?

No documentation per se. However, every warning/error that is remappable displays the corresponding flag as part of the diagnostic. Note the [-Wreturn-type] in the diagnostic you pasted. 

  -Doug



More information about the cfe-dev mailing list