BUILTIN(__builtin_nontemporal_load, "v.", "t")
// Coroutine intrinsics.
-BUILTIN(__builtin_coro_resume, "vv*", "")
-BUILTIN(__builtin_coro_destroy, "vv*", "")
-BUILTIN(__builtin_coro_done, "bv*", "n")
-BUILTIN(__builtin_coro_promise, "v*v*IiIb", "n")
-
-BUILTIN(__builtin_coro_size, "z", "n")
-BUILTIN(__builtin_coro_frame, "v*", "n")
-BUILTIN(__builtin_coro_noop, "v*", "n")
-BUILTIN(__builtin_coro_free, "v*v*", "n")
-
-BUILTIN(__builtin_coro_id, "v*Iiv*v*v*", "n")
-BUILTIN(__builtin_coro_alloc, "b", "n")
-BUILTIN(__builtin_coro_begin, "v*v*", "n")
-BUILTIN(__builtin_coro_end, "bv*Ib", "n")
-BUILTIN(__builtin_coro_suspend, "cIb", "n")
-BUILTIN(__builtin_coro_param, "bv*v*", "n")
+LANGBUILTIN(__builtin_coro_resume, "vv*", "", COR_LANG)
+LANGBUILTIN(__builtin_coro_destroy, "vv*", "", COR_LANG)
+LANGBUILTIN(__builtin_coro_done, "bv*", "n", COR_LANG)
+LANGBUILTIN(__builtin_coro_promise, "v*v*IiIb", "n", COR_LANG)
+
+LANGBUILTIN(__builtin_coro_size, "z", "n", COR_LANG)
+LANGBUILTIN(__builtin_coro_frame, "v*", "n", COR_LANG)
+LANGBUILTIN(__builtin_coro_noop, "v*", "n", COR_LANG)
+LANGBUILTIN(__builtin_coro_free, "v*v*", "n", COR_LANG)
+
+LANGBUILTIN(__builtin_coro_id, "v*Iiv*v*v*", "n", COR_LANG)
+LANGBUILTIN(__builtin_coro_alloc, "b", "n", COR_LANG)
+LANGBUILTIN(__builtin_coro_begin, "v*v*", "n", COR_LANG)
+LANGBUILTIN(__builtin_coro_end, "bv*Ib", "n", COR_LANG)
+LANGBUILTIN(__builtin_coro_suspend, "cIb", "n", COR_LANG)
+LANGBUILTIN(__builtin_coro_param, "bv*v*", "n", COR_LANG)
// OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
// We need the generic prototype, since the packet type could be anything.
bool BuiltinsUnsupported =
(LangOpts.NoBuiltin || LangOpts.isNoBuiltinFunc(BuiltinInfo.Name)) &&
strchr(BuiltinInfo.Attributes, 'f');
+ bool CorBuiltinsUnsupported =
+ !LangOpts.Coroutines && (BuiltinInfo.Langs & COR_LANG);
bool MathBuiltinsUnsupported =
LangOpts.NoMathBuiltin && BuiltinInfo.HeaderName &&
llvm::StringRef(BuiltinInfo.HeaderName).equals("math.h");
bool CUDAUnsupported = !LangOpts.CUDA && BuiltinInfo.Langs == CUDA_LANG;
bool CPlusPlusUnsupported =
!LangOpts.CPlusPlus && BuiltinInfo.Langs == CXX_LANG;
- return !BuiltinsUnsupported && !MathBuiltinsUnsupported && !OclCUnsupported &&
- !OclC1Unsupported && !OclC2Unsupported && !OpenMPUnsupported &&
- !GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported &&
- !CPlusPlusUnsupported && !CUDAUnsupported;
+ return !BuiltinsUnsupported && !CorBuiltinsUnsupported &&
+ !MathBuiltinsUnsupported && !OclCUnsupported && !OclC1Unsupported &&
+ !OclC2Unsupported && !OpenMPUnsupported && !GnuModeUnsupported &&
+ !MSModeUnsupported && !ObjCUnsupported && !CPlusPlusUnsupported &&
+ !CUDAUnsupported;
}
/// initializeBuiltins - Mark the identifiers for all the builtins with their
--- /dev/null
+// RUN: %clang_cc1 -fsyntax-only -verify -fcoroutines-ts %s
+// RUN: %clang_cc1 -fsyntax-only -verify -DERRORS %s
+
+// Check that we don't crash when using __builtin_coro_* without the fcoroutine-ts option
+
+#ifdef ERRORS
+// expected-error@#A{{use of undeclared identifier '__builtin_coro_done'}}
+// expected-error@#B{{use of undeclared identifier '__builtin_coro_id'}}
+// expected-error@#C{{use of undeclared identifier '__builtin_coro_alloc'}}
+#else
+// expected-no-diagnostics
+#endif
+
+int main() {
+ void *co_h;
+ bool d = __builtin_coro_done(co_h); // #A
+ __builtin_coro_id(32, 0, 0, 0); // #B
+ __builtin_coro_alloc(); // #C
+}