aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-10-21 16:57:46 +0000
committerDouglas Gregor <dgregor@apple.com>2010-10-21 16:57:46 +0000
commit0bab54cf82cd679152197c7a2eb938f8aa9f07dd (patch)
tree4e334ad9bd43920c29d7d58b7c1697d1ac412d89 /lib/Sema/SemaDecl.cpp
parent9ee5ee84f0ad8246bff105786a128c7a909fdf12 (diff)
Always treat 'main' as an extern "C" function, so that we detect
redeclarations of main appropriately rather than allowing it to be overloaded. Also, disallowing declaring main as a template. Fixes GCC DejaGNU g++.old-deja/g++.other/main1.C. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117029 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 57cbb46480..f1045d3c0b 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -4182,6 +4182,11 @@ void Sema::CheckMain(FunctionDecl* FD) {
if (nparams == 1 && !FD->isInvalidDecl()) {
Diag(FD->getLocation(), diag::warn_main_one_arg);
}
+
+ if (!FD->isInvalidDecl() && FD->getDescribedFunctionTemplate()) {
+ Diag(FD->getLocation(), diag::err_main_template_decl);
+ FD->setInvalidDecl();
+ }
}
bool Sema::CheckForConstantInitializer(Expr *Init, QualType DclT) {