From: Rafael Espindola Date: Sat, 12 Jan 2013 01:47:40 +0000 (+0000) Subject: Fix a regression from 171193: main cannot be overloaded. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a525acb2ba57ea03cfc8f843bfb2e5f81caf65f;p=clang Fix a regression from 171193: main cannot be overloaded. Thanks Eli Friedman for noticing it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172292 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index bb38222a65..44ff3a505e 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -935,6 +935,11 @@ static bool canBeOverloaded(const FunctionDecl &D) { return true; if (D.hasCLanguageLinkage()) return false; + + // Main cannot be overloaded (basic.start.main). + if (D.isMain()) + return false; + return true; } diff --git a/test/SemaCXX/overload-decl.cpp b/test/SemaCXX/overload-decl.cpp index c610ff7ab0..9bba47adfd 100644 --- a/test/SemaCXX/overload-decl.cpp +++ b/test/SemaCXX/overload-decl.cpp @@ -29,3 +29,6 @@ class X { static void g(float); static void g(int); // expected-error {{static and non-static member functions with the same parameter types cannot be overloaded}} }; + +int main() {} // expected-note {{previous definition is here}} +int main(int,char**) {} // expected-error {{conflicting types for 'main'}}