[cfe-commits] r172292 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/overload-decl.cpp

Rafael Espindola rafael.espindola at gmail.com
Fri Jan 11 17:47:40 PST 2013


Author: rafael
Date: Fri Jan 11 19:47:40 2013
New Revision: 172292

URL: http://llvm.org/viewvc/llvm-project?rev=172292&view=rev
Log:
Fix a regression from 171193: main cannot be overloaded.
Thanks Eli Friedman for noticing it.

Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/overload-decl.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=172292&r1=172291&r2=172292&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Jan 11 19:47:40 2013
@@ -935,6 +935,11 @@
     return true;
   if (D.hasCLanguageLinkage())
     return false;
+
+  // Main cannot be overloaded (basic.start.main).
+  if (D.isMain())
+    return false;
+
   return true;
 }
 

Modified: cfe/trunk/test/SemaCXX/overload-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overload-decl.cpp?rev=172292&r1=172291&r2=172292&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/overload-decl.cpp (original)
+++ cfe/trunk/test/SemaCXX/overload-decl.cpp Fri Jan 11 19:47:40 2013
@@ -29,3 +29,6 @@
   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'}}





More information about the cfe-commits mailing list