r336748 - Remove qualtype qualifier in coroutine error to prevent assert in debug
Brian Gesiak via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 10 17:45:48 PDT 2018
Author: modocache
Date: Tue Jul 10 17:45:48 2018
New Revision: 336748
URL: http://llvm.org/viewvc/llvm-project?rev=336748&view=rev
Log:
Remove qualtype qualifier in coroutine error to prevent assert in debug
Summary:
A forward-declared coroutine_traits should trip an error; we need
a complete type.
Unfortunately, in debug mode only, we trip an assert when attempting
to provide the fully qualified type for the error message.
If you try to compile a program with a forward-declared
coroutine_traits in debug mode, clang will crash.
I've included a test for the behavior and removed the q modifier
on the error message. This prevents the crash in debug mode and
does not change the behavior for the error message on a
forward-declaration of a coroutine_traits type.
Test Plan:
I've included a test for the forward-declaration.
Patch by Tanoy Sinha!
Reviewers: modocache, GorNishanov
Reviewed By: modocache
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D49099
Added:
cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=336748&r1=336747&r2=336748&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jul 10 17:45:48 2018
@@ -9082,7 +9082,7 @@ def err_coroutine_promise_type_incomplet
"this function cannot be a coroutine: %0 is an incomplete type">;
def err_coroutine_type_missing_specialization : Error<
"this function cannot be a coroutine: missing definition of "
- "specialization %q0">;
+ "specialization %0">;
def err_coroutine_promise_incompatible_return_functions : Error<
"the coroutine promise type %0 declares both 'return_value' and 'return_void'">;
def err_coroutine_promise_requires_return_function : Error<
Added: cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp?rev=336748&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp (added)
+++ cfe/trunk/test/SemaCXX/coroutine-traits-undefined-template.cpp Tue Jul 10 17:45:48 2018
@@ -0,0 +1,21 @@
+// test/SemaCXX/coroutine-traits-undefined-template.cpp
+
+// This file contains references to sections of the Coroutines TS, which can be
+// found at http://wg21.link/coroutines.
+
+// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -verify %s -fcxx-exceptions -fexceptions -Wunused-result
+
+namespace std {
+namespace experimental {
+
+template<typename ...T>
+struct coroutine_traits {
+ struct promise_type {};
+};
+
+template<> struct coroutine_traits<void>; // expected-note {{forward declaration of 'std::experimental::coroutine_traits<void>'}}
+}} // namespace std::experimental
+
+void uses_forward_declaration() {
+ co_return; // expected-error {{this function cannot be a coroutine: missing definition of specialization 'coroutine_traits<void>'}}
+}
More information about the cfe-commits
mailing list