Author: rsmith Date: Wed Nov 18 20:36:35 2015 New Revision: 253535 URL: http://llvm.org/viewvc/llvm-project?rev=253535&view=rev Log: [coroutines] Tweak diagnostics to always use fully-qualified name for std::coroutine_traits.
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaCoroutine.cpp cfe/trunk/test/SemaCXX/coroutines.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=253535&r1=253534&r2=253535&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Nov 18 20:36:35 2015 @@ -7971,14 +7971,14 @@ def ext_coroutine_without_co_await_co_yi def err_implied_std_coroutine_traits_not_found : Error< "you need to include <coroutine> before defining a coroutine">; def err_malformed_std_coroutine_traits : Error< - "std::coroutine_traits must be a class template">; + "'std::coroutine_traits' must be a class template">; def err_implied_std_coroutine_traits_promise_type_not_found : Error< - "this function cannot be a coroutine: %0 has no member named 'promise_type'">; + "this function cannot be a coroutine: %q0 has no member named 'promise_type'">; def err_implied_std_coroutine_traits_promise_type_not_class : Error< "this function cannot be a coroutine: %0 is not a class">; def err_coroutine_traits_missing_specialization : Error< "this function cannot be a coroutine: missing definition of " - "specialization %0">; + "specialization %q0">; } let CategoryName = "Documentation Issue" in { Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=253535&r1=253534&r2=253535&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original) +++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Wed Nov 18 20:36:35 2015 @@ -82,6 +82,12 @@ static QualType lookupPromiseType(Sema & // The promise type is required to be a class type. QualType PromiseType = S.Context.getTypeDeclType(Promise); if (!PromiseType->getAsCXXRecordDecl()) { + // Use the fully-qualified name of the type. + auto *NNS = NestedNameSpecifier::Create(S.Context, nullptr, Std); + NNS = NestedNameSpecifier::Create(S.Context, NNS, false, + CoroTrait.getTypePtr()); + PromiseType = S.Context.getElaboratedType(ETK_None, NNS, PromiseType); + S.Diag(Loc, diag::err_implied_std_coroutine_traits_promise_type_not_class) << PromiseType; return QualType(); Modified: cfe/trunk/test/SemaCXX/coroutines.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=253535&r1=253534&r2=253535&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/coroutines.cpp (original) +++ cfe/trunk/test/SemaCXX/coroutines.cpp Wed Nov 18 20:36:35 2015 @@ -21,7 +21,12 @@ void no_specialization() { template<typename ...T> struct std::coroutine_traits<int, T...> {}; int no_promise_type() { - co_await a; // expected-error {{this function cannot be a coroutine: 'coroutine_traits<int>' has no member named 'promise_type'}} + co_await a; // expected-error {{this function cannot be a coroutine: 'std::coroutine_traits<int>' has no member named 'promise_type'}} +} + +template<> struct std::coroutine_traits<double, double> { typedef int promise_type; }; +double bad_promise_type(double) { + co_await a; // expected-error {{this function cannot be a coroutine: 'std::coroutine_traits<double, double>::promise_type' (aka 'int') is not a class}} } struct promise; // expected-note {{forward declaration}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits