summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-01-17 22:16:11 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-01-17 22:16:11 +0000
commit0015f0987792014c9f9daf595c8f4594cb465213 (patch)
tree4f60f278c12f3861df6718e1a61c31082b81f2ea /clang/lib/Sema/SemaDecl.cpp
parent01a7fba820a612d55d2c09ab734f4c774ba6aa0a (diff)
downloadbcm5719-llvm-0015f0987792014c9f9daf595c8f4594cb465213.tar.gz
bcm5719-llvm-0015f0987792014c9f9daf595c8f4594cb465213.zip
Parsing support for C11's _Noreturn keyword. No semantics yet.
llvm-svn: 172761
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index a13d8b3b462..9cf5e73665a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -4097,6 +4097,10 @@ void Sema::DiagnoseFunctionSpecifiers(Declarator& D) {
if (D.getDeclSpec().isExplicitSpecified())
Diag(D.getDeclSpec().getExplicitSpecLoc(),
diag::err_explicit_non_function);
+
+ if (D.getDeclSpec().isNoreturnSpecified())
+ Diag(D.getDeclSpec().getNoreturnSpecLoc(),
+ diag::err_noreturn_non_function);
}
NamedDecl*
@@ -6429,9 +6433,10 @@ static SourceRange getResultSourceRange(const FunctionDecl *FD) {
void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) {
// 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.
+ // C11 6.7.4p4: In a hosted environment, no function specifier(s) shall
+ // appear in a declaration of main.
// static main is not an error under C99, but we should warn about it.
+ // We accept _Noreturn main as an extension.
if (FD->getStorageClass() == SC_Static)
Diag(DS.getStorageClassSpecLoc(), getLangOpts().CPlusPlus
? diag::err_static_main : diag::warn_static_main)
@@ -6439,6 +6444,8 @@ void Sema::CheckMain(FunctionDecl* FD, const DeclSpec& DS) {
if (FD->isInlineSpecified())
Diag(DS.getInlineSpecLoc(), diag::err_inline_main)
<< FixItHint::CreateRemoval(DS.getInlineSpecLoc());
+ if (DS.isNoreturnSpecified())
+ Diag(DS.getNoreturnSpecLoc(), diag::ext_noreturn_main);
if (FD->isConstexpr()) {
Diag(DS.getConstexprSpecLoc(), diag::err_constexpr_main)
<< FixItHint::CreateRemoval(DS.getConstexprSpecLoc());
OpenPOWER on IntegriCloud