if (!getLangOpts().CPlusPlus) {
// Perform semantic checking on the function declaration.
bool isExplicitSpecialization=false;
- if (!NewFD->isInvalidDecl()) {
- if (NewFD->isMain())
- CheckMain(NewFD, D.getDeclSpec());
+ if (!NewFD->isInvalidDecl() && NewFD->isMain())
+ CheckMain(NewFD, D.getDeclSpec());
+
+ if (!NewFD->isInvalidDecl())
D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous,
isExplicitSpecialization));
- }
// Make graceful recovery from an invalid redeclaration.
else if (!Previous.empty())
D.setRedeclaration(true);
// Perform semantic checking on the function declaration.
if (!isDependentClassScopeExplicitSpecialization) {
+ if (!NewFD->isInvalidDecl() && NewFD->isMain())
+ CheckMain(NewFD, D.getDeclSpec());
+
if (NewFD->isInvalidDecl()) {
// If this is a class member, mark the class invalid immediately.
// This avoids some consistency errors later.
if (CXXMethodDecl* methodDecl = dyn_cast<CXXMethodDecl>(NewFD))
methodDecl->getParent()->setInvalidDecl();
- } else {
- if (NewFD->isMain())
- CheckMain(NewFD, D.getDeclSpec());
+ } else
D.setRedeclaration(CheckFunctionDeclaration(S, NewFD, Previous,
isExplicitSpecialization));
- }
}
assert((NewFD->isInvalidDecl() || !D.isRedeclaration() ||
// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST10
// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST11
// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST12
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST12
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DTEST13
#if TEST1
typedef char charT;
int main(int, const charT* const *) {}
+#elif TEST13
+
+int main(void) {}
+
+template <typename T>
+int main(void); // expected-error{{'main' cannot be a template}}
+
#else
#error Unknown test mode