summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-09-30 22:38:31 +0000
committerEric Fiselier <eric@efcs.ca>2016-09-30 22:38:31 +0000
commit7d5773e6108d92a8b259e9d4d58ecf1027d06a4f (patch)
tree91c756b339ccfdcfe5da45763a0bfd171acfa4de /clang/lib
parent7022b9468774886e6039867436b2ee26801c436a (diff)
downloadbcm5719-llvm-7d5773e6108d92a8b259e9d4d58ecf1027d06a4f.tar.gz
bcm5719-llvm-7d5773e6108d92a8b259e9d4d58ecf1027d06a4f.zip
[coroutines] Diagnose when 'main' is declared as a coroutine.
Summary: The title says it all. Reviewers: rsmith, GorNishanov Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D25078 llvm-svn: 282973
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaCoroutine.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index 51430360886..461ca8eddcf 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -127,6 +127,11 @@ checkCoroutineContext(Sema &S, SourceLocation Loc, StringRef Keyword) {
S.Diag(Loc, diag::err_coroutine_constexpr) << Keyword;
} else if (FD->isVariadic()) {
S.Diag(Loc, diag::err_coroutine_varargs) << Keyword;
+ } else if (FD->isMain()) {
+ S.Diag(FD->getLocStart(), diag::err_coroutine_main);
+ S.Diag(Loc, diag::note_declared_coroutine_here)
+ << (Keyword == "co_await" ? 0 :
+ Keyword == "co_yield" ? 1 : 2);
} else {
auto *ScopeInfo = S.getCurFunction();
assert(ScopeInfo && "missing function scope for function");
OpenPOWER on IntegriCloud