aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-02-04 06:10:17 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-02-04 06:10:17 +0000
commita506586ad3cb0f3635b0e77b86e5e9e5fb2ccc17 (patch)
treedd7902c32ff3f732f4d99274e9b6d8a29feee2d0 /lib/Sema/SemaDecl.cpp
parent0b458fd8b6321c11e8b22727e0e9b9960e93ff4d (diff)
Disallow constexpr main.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149770 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index f6f97dddbc..0e5e6781a6 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -5778,8 +5778,8 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD,
}
void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) {
- // C++ [basic.start.main]p3: A program that declares main to be inline
- // or static is ill-formed.
+ // C++11 [basic.start.main]p3: A program that declares main to be inline,
+ // static or constexpr is ill-formed.
// C99 6.7.4p4: In a hosted environment, the inline function specifier
// shall not appear in a declaration of main.
// static main is not an error under C99, but we should warn about it.
@@ -5790,6 +5790,11 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) {
if (FD->isInlineSpecified())
Diag(DS.getInlineSpecLoc(), diag::err_inline_main)
<< FixItHint::CreateRemoval(DS.getInlineSpecLoc());
+ if (FD->isConstexpr()) {
+ Diag(DS.getConstexprSpecLoc(), diag::err_constexpr_main)
+ << FixItHint::CreateRemoval(DS.getConstexprSpecLoc());
+ FD->setConstexpr(false);
+ }
QualType T = FD->getType();
assert(T->isFunctionType() && "function decl is not of function type");