Bug 51186 - declaring main() with auto but without --std=c++11 gives inconsistent error messages
Summary: declaring main() with auto but without --std=c++11 gives inconsistent error m...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 minor
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-17 08:47 UTC by wswiktor
Modified: 2011-11-17 21:05 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 wswiktor 2011-11-17 08:47:40 UTC
When I try to compile this code without specifying C++11 or C++0x standard

    auto main()->int
    {
    }

the following conflicting messages are generated:

    cpp.cpp:1:14: error: top-level declaration of 'main' specifies 'auto'
    cpp.cpp:1:14: error: 'main' function with late return type not declared with 'auto' type specifier

The second one should be disabled when not in C++11 mode, or replaced with one saying that funtions with late return type are not allowed.
Comment 1 Jason Merrill 2011-11-17 21:00:34 UTC
Author: jason
Date: Thu Nov 17 21:00:30 2011
New Revision: 181455

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181455
Log:
	PR c++/51186
	* decl.c (grokdeclarator): Improve C++98 trailing return diagnostic.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/auto27.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/cpp0x/trailing2.C
Comment 2 Jason Merrill 2011-11-17 21:05:00 UTC
Fixed to say

x.C:3:14: error: trailing return type only available with -std=c++11 or -std=gnu++11