[cfe-commits] [LLVMdev] clang errors on void main()
dblaikie at gmail.com
Wed Feb 8 13:47:50 CST 2012
On Wed, Feb 8, 2012 at 11:25 AM, Chris Lattner <clattner at apple.com> wrote:
> On Feb 8, 2012, at 5:31 AM, Vasiliy Korchagin wrote:
>> 07.02.2012 07:27, Eli Friedman пишет:
>>> On Mon, Feb 6, 2012 at 6:51 PM, Xin Tong<xerox.time.tech at gmail.com> wrote:
>>>> Is there any way to stop this ?
>>>> error: 'main' must return 'int'
>>>> void main()
>>>> 1 error generated.
>>> You mean besides fixing the source of your benchmark so it's valid C?
>>> Not at the moment... patches welcome.
>> We suggest patch for allowing main() function to have non-integer return type. This feature can be enabled with "-allow-non-int-main" option. In this case warning about incorrect main() return type will be printed instead of error.
>> In patch also included test case for this feature.
>> Vasiliy Korchagin,
> Hi Vasiliy,
> Please send clang patches to cfe-dev.
or even cfe-commits (further instructions are here:
[I've dropped llvm-dev and added cfe-commits to this email]
My first thought based on your description alone would be that we
should support this, if at all, probably in the way that GCC already
does - surfacing non-int returning main as a warning in C (under
-Wmain) and error in C++ (as it is already) if that's practical.
& looking at the patch itself: Your change is even more permissive
than GCC (when you use the flag you've added) allowing C++ to have
void returning main. I don't see any need to be so accepting.
(& the change you've made in Sema::ActOnFinishFunctionBody scares me a
bit - what does that do when you have int returning main but you turn
this flag on? not allow implicit return 0? that seems problematic)
More information about the cfe-commits