]> granicus.if.org Git - clang/commitdiff
Enable coroutines under -std=c++2a.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 23 Feb 2019 21:06:26 +0000 (21:06 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sat, 23 Feb 2019 21:06:26 +0000 (21:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354736 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/LangOptions.def
include/clang/Basic/TokenKinds.def
lib/Basic/IdentifierTable.cpp
lib/Basic/Module.cpp
lib/CodeGen/BackendUtil.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Frontend/InitPreprocessor.cpp
lib/Sema/SemaDecl.cpp
test/Lexer/cxx-features.cpp
test/Lexer/cxx2a_keyword_as_cxx17.cpp
www/cxx_status.html

index 9df5550f80ebc84aabf8069f62c4af54bb3d4da9..106f776ad15dbd11cc02a5f4eee24742a15e506f 100644 (file)
@@ -136,7 +136,7 @@ LANGOPT(Freestanding, 1, 0, "freestanding implementation")
 LANGOPT(NoBuiltin         , 1, 0, "disable builtin functions")
 LANGOPT(NoMathBuiltin     , 1, 0, "disable math builtin functions")
 LANGOPT(GNUAsm            , 1, 1, "GNU-style inline assembly")
-LANGOPT(CoroutinesTS      , 1, 0, "C++ coroutines TS")
+LANGOPT(Coroutines        , 1, 0, "C++20 coroutines")
 LANGOPT(DllExportInlines  , 1, 1, "dllexported classes dllexport inline methods")
 LANGOPT(RelaxedTemplateTemplateArgs, 1, 0, "C++17 relaxed matching of template template arguments")
 
index 01b2f62325071da94a679b2d113a70b47328eff3..93d741221d7d540a77ea007a37182f5962ae346a 100644 (file)
@@ -32,6 +32,9 @@
 #ifndef CONCEPTS_KEYWORD
 #define CONCEPTS_KEYWORD(X) CXX2A_KEYWORD(X,KEYCONCEPTS)
 #endif
+#ifndef COROUTINES_KEYWORD
+#define COROUTINES_KEYWORD(X) CXX2A_KEYWORD(X,KEYCOROUTINES)
+#endif
 #ifndef MODULES_KEYWORD
 #define MODULES_KEYWORD(X) KEYWORD(X,KEYMODULES)
 #endif
@@ -254,8 +257,7 @@ PUNCTUATOR(caretcaret,            "^^")
 //   KEYZVECTOR - This is a keyword for the System z vector extensions,
 //                which are heavily based on AltiVec
 //   KEYBORLAND - This is a keyword if Borland extensions are enabled
-//   KEYCOROUTINES - This is a keyword if support for the C++ coroutines
-//                   TS is enabled
+//   KEYCOROUTINES - This is a keyword if support for C++ coroutines is enabled
 //   BOOLSUPPORT - This is a keyword if 'bool' is a built-in type
 //   HALFSUPPORT - This is a keyword if 'half' is a built-in type
 //   WCHARSUPPORT - This is a keyword if 'wchar_t' is a built-in type
@@ -371,17 +373,17 @@ CXX11_KEYWORD(thread_local          , 0)
 CONCEPTS_KEYWORD(concept)
 CONCEPTS_KEYWORD(requires)
 
-// C++ coroutines TS keywords
-KEYWORD(co_await                    , KEYCOROUTINES)
-KEYWORD(co_return                   , KEYCOROUTINES)
-KEYWORD(co_yield                    , KEYCOROUTINES)
+// C++2a / coroutines TS keywords
+COROUTINES_KEYWORD(co_await)
+COROUTINES_KEYWORD(co_return)
+COROUTINES_KEYWORD(co_yield)
 
 // C++ modules TS keywords
 MODULES_KEYWORD(module)
 MODULES_KEYWORD(import)
 
 // C++ char8_t proposal
-KEYWORD(char8_t                     , CHAR8SUPPORT)
+CXX2A_KEYWORD(char8_t               , CHAR8SUPPORT)
 
 // C11 Extension
 KEYWORD(_Float16                    , KEYALL)
index 7dfcc9c46d0d1e1681d2db7ff7b4695673857c87..5dee8f09a58e785a3faefef6739002f446c22506 100644 (file)
@@ -143,7 +143,7 @@ static KeywordStatus getKeywordStatus(const LangOptions &LangOpts,
   // in non-arc mode.
   if (LangOpts.ObjC && (Flags & KEYOBJC)) return KS_Enabled;
   if (LangOpts.ConceptsTS && (Flags & KEYCONCEPTS)) return KS_Enabled;
-  if (LangOpts.CoroutinesTS && (Flags & KEYCOROUTINES)) return KS_Enabled;
+  if (LangOpts.Coroutines && (Flags & KEYCOROUTINES)) return KS_Enabled;
   if (LangOpts.ModulesTS && (Flags & KEYMODULES)) return KS_Enabled;
   if (LangOpts.CPlusPlus && (Flags & KEYALLCXX)) return KS_Future;
   return KS_Disabled;
index 52583250dac9343e40903677d298f1abf4590581..b405ab621d31ed1e72e587c00f23df0113ec53ce 100644 (file)
@@ -108,7 +108,7 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,
   bool HasFeature = llvm::StringSwitch<bool>(Feature)
                         .Case("altivec", LangOpts.AltiVec)
                         .Case("blocks", LangOpts.Blocks)
-                        .Case("coroutines", LangOpts.CoroutinesTS)
+                        .Case("coroutines", LangOpts.Coroutines)
                         .Case("cplusplus", LangOpts.CPlusPlus)
                         .Case("cplusplus11", LangOpts.CPlusPlus11)
                         .Case("cplusplus14", LangOpts.CPlusPlus14)
index 8f9ea093c9624a33cece9bd8eadfb1ba2427d94d..2f71664371d75bd8283db5771d13bb75196acc48 100644 (file)
@@ -581,7 +581,7 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
                            addObjCARCOptPass);
   }
 
-  if (LangOpts.CoroutinesTS)
+  if (LangOpts.Coroutines)
     addCoroutinePassesToExtensionPoints(PMBuilder);
 
   if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds)) {
index 1a33a00004d6068b38d7f8a496b0b33afc038bde..3c4196d3ddc15ad20c80951243cbd88c4bf634f9 100644 (file)
@@ -2577,7 +2577,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   Opts.Blocks = Args.hasArg(OPT_fblocks) || (Opts.OpenCL
     && Opts.OpenCLVersion == 200);
   Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);
-  Opts.CoroutinesTS = Args.hasArg(OPT_fcoroutines_ts);
+  Opts.Coroutines = Opts.CPlusPlus2a || Args.hasArg(OPT_fcoroutines_ts);
 
   // Enable [[]] attributes in C++11 by default.
   Opts.DoubleSquareBracketAttributes =
index e0e428ade2940e9ccb9dee2585ffeeaefb429060..c9f9f644f37c13db6f47e738837543faa6a9c592 100644 (file)
@@ -547,7 +547,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
   // TS features.
   if (LangOpts.ConceptsTS)
     Builder.defineMacro("__cpp_experimental_concepts", "1L");
-  if (LangOpts.CoroutinesTS)
+  if (LangOpts.Coroutines)
     Builder.defineMacro("__cpp_coroutines", "201703L");
 }
 
index d6e44af0ebeb033ca9a728db9d80002881714fbf..cbef0e2bb467e95242477c3af551e7cb735ba5f0 100644 (file)
@@ -13116,7 +13116,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
   sema::AnalysisBasedWarnings::Policy WP = AnalysisWarnings.getDefaultPolicy();
   sema::AnalysisBasedWarnings::Policy *ActivePolicy = nullptr;
 
-  if (getLangOpts().CoroutinesTS && getCurFunction()->isCoroutine())
+  if (getLangOpts().Coroutines && getCurFunction()->isCoroutine())
     CheckCompletedCoroutineBody(FD, Body);
 
   // Do not call PopExpressionEvaluationContext() if it is a lambda because one
index 706a02fc8a66a3d270ceae939709c7017980feb7..75d6e0aa14dd3d452200ecb97227175fc0804333 100644 (file)
 #error "wrong value for __cpp_experimental_concepts"
 #endif
 
-#if defined(COROUTINES) ? check(coroutines, 201703L, 201703L, 201703L, 201703L, 201703L) : check(coroutines, 0, 0, 0, 0, 0)
+#if defined(COROUTINES) ? check(coroutines, 201703L, 201703L, 201703L, 201703L, 201703L) : check(coroutines, 0, 0, 0, 0, 201703L)
 #error "wrong value for __cpp_coroutines"
 #endif
index c6a821be0ea717c66cb38d06178d04c6800a723c..d2ed7d33803ab879c61508342b522184bf55fd42 100644 (file)
@@ -5,5 +5,9 @@ template<typename T>
 concept x = 0;
 #undef concept
 
+int co_await = 0; // expected-warning {{'co_await' is a keyword in C++2a}}
+int co_return = 0; // expected-warning {{'co_return' is a keyword in C++2a}}
+int co_yield = 0; // expected-warning {{'co_yield' is a keyword in C++2a}}
+int char8_t = 0; // expected-warning {{'char8_t' is a keyword in C++2a}}
 int concept = 0; // expected-warning {{'concept' is a keyword in C++2a}}
 int requires = 0; // expected-warning {{'requires' is a keyword in C++2a}}
index 3d0090a54916ba3421b5d5ced4de8a7ae198f0d2..5438914d404e48385310a78f1542441193b45e3a 100755 (executable)
@@ -1060,7 +1060,7 @@ as the draft C++2a standard evolves.
     <tr>
       <td>Coroutines</td>
       <td><a href="http://wg21.link/p0912r5">P0912R5</a></td>
-      <td class="partial" align="center">Partial (<tt>-fcoroutines-ts</tt>)</td>
+      <td class="partial" align="center">Partial</td>
     </tr>
 </table>