Quuxplusone updated this revision to Diff 176955. Quuxplusone added a comment.
Rename `-Wc++14-compat-ctad` to just `-Wctad`, per @rsmith's comment to "move this out of `-Wc++14-compat`." @rsmith ping? Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D54565/new/ https://reviews.llvm.org/D54565 Files: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td test/SemaCXX/cxx14-compat-ctad.cpp Index: test/SemaCXX/cxx14-compat-ctad.cpp =================================================================== --- /dev/null +++ test/SemaCXX/cxx14-compat-ctad.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wctad -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++2a -Wctad -verify %s + +template<typename T = int> struct X {}; +X x; // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17; for compatibility, use explicit type name 'X<int>'}} + +template<template<typename> class> struct Y {}; +Y<X> yx; // ok, not class template argument deduction + +template<typename T> void f(T t) { + X x = t; // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17}} +} + +template<typename T> void g(T t) { + typename T::X x = t; // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17; for compatibility, use explicit type name 'typename A::X<A>' (aka 'A::X<A>')}} +} + +struct A { template<typename T> struct X { X(T); }; }; +void h(A a) { g(a); } // expected-note {{in instantiation of function template specialization 'g<A>'}} + +template<class T> struct V { V(const T&) {} }; + +V(int) -> V<int*>; // ok, deduction guide is not a use of class template argument deduction + +void f2() { V v('a'); } // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17; for compatibility, use explicit type name 'V<char>'}} +void g2() { V v(0); } // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17; for compatibility, use explicit type name 'V<int *>'}} + +void h2() { + auto lam = [](){}; + V v(lam); // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17}} +} Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -2159,7 +2159,7 @@ def warn_cxx14_compat_class_template_argument_deduction : Warning< "class template argument deduction is incompatible with C++ standards " "before C++17%select{|; for compatibility, use explicit type name %1}0">, - InGroup<CXXPre17Compat>, DefaultIgnore; + InGroup<CTAD>, DefaultIgnore; // C++14 deduced return types def err_auto_fn_deduction_failure : Error< Index: include/clang/Basic/DiagnosticGroups.td =================================================================== --- include/clang/Basic/DiagnosticGroups.td +++ include/clang/Basic/DiagnosticGroups.td @@ -175,6 +175,7 @@ def InvalidIOSDeploymentTarget : DiagGroup<"invalid-ios-deployment-target">; +def CTAD : DiagGroup<"ctad">; def CXX17CompatMangling : DiagGroup<"c++17-compat-mangling">; def : DiagGroup<"c++1z-compat-mangling", [CXX17CompatMangling]>; // Name of this warning in GCC. @@ -185,7 +186,8 @@ def CXXPre14CompatPedantic : DiagGroup<"c++98-c++11-compat-pedantic", [CXXPre14Compat, CXXPre14CompatBinaryLiteral]>; -def CXXPre17Compat : DiagGroup<"c++98-c++11-c++14-compat">; +def CXXPre17Compat : DiagGroup<"c++98-c++11-c++14-compat", + [CTAD]>; def CXXPre17CompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic", [CXXPre17Compat]>; def CXXPre2aCompat : DiagGroup<"c++98-c++11-c++14-c++17-compat">;
Index: test/SemaCXX/cxx14-compat-ctad.cpp =================================================================== --- /dev/null +++ test/SemaCXX/cxx14-compat-ctad.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wctad -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++2a -Wctad -verify %s + +template<typename T = int> struct X {}; +X x; // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17; for compatibility, use explicit type name 'X<int>'}} + +template<template<typename> class> struct Y {}; +Y<X> yx; // ok, not class template argument deduction + +template<typename T> void f(T t) { + X x = t; // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17}} +} + +template<typename T> void g(T t) { + typename T::X x = t; // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17; for compatibility, use explicit type name 'typename A::X<A>' (aka 'A::X<A>')}} +} + +struct A { template<typename T> struct X { X(T); }; }; +void h(A a) { g(a); } // expected-note {{in instantiation of function template specialization 'g<A>'}} + +template<class T> struct V { V(const T&) {} }; + +V(int) -> V<int*>; // ok, deduction guide is not a use of class template argument deduction + +void f2() { V v('a'); } // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17; for compatibility, use explicit type name 'V<char>'}} +void g2() { V v(0); } // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17; for compatibility, use explicit type name 'V<int *>'}} + +void h2() { + auto lam = [](){}; + V v(lam); // expected-warning {{class template argument deduction is incompatible with C++ standards before C++17}} +} Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -2159,7 +2159,7 @@ def warn_cxx14_compat_class_template_argument_deduction : Warning< "class template argument deduction is incompatible with C++ standards " "before C++17%select{|; for compatibility, use explicit type name %1}0">, - InGroup<CXXPre17Compat>, DefaultIgnore; + InGroup<CTAD>, DefaultIgnore; // C++14 deduced return types def err_auto_fn_deduction_failure : Error< Index: include/clang/Basic/DiagnosticGroups.td =================================================================== --- include/clang/Basic/DiagnosticGroups.td +++ include/clang/Basic/DiagnosticGroups.td @@ -175,6 +175,7 @@ def InvalidIOSDeploymentTarget : DiagGroup<"invalid-ios-deployment-target">; +def CTAD : DiagGroup<"ctad">; def CXX17CompatMangling : DiagGroup<"c++17-compat-mangling">; def : DiagGroup<"c++1z-compat-mangling", [CXX17CompatMangling]>; // Name of this warning in GCC. @@ -185,7 +186,8 @@ def CXXPre14CompatPedantic : DiagGroup<"c++98-c++11-compat-pedantic", [CXXPre14Compat, CXXPre14CompatBinaryLiteral]>; -def CXXPre17Compat : DiagGroup<"c++98-c++11-c++14-compat">; +def CXXPre17Compat : DiagGroup<"c++98-c++11-c++14-compat", + [CTAD]>; def CXXPre17CompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic", [CXXPre17Compat]>; def CXXPre2aCompat : DiagGroup<"c++98-c++11-c++14-c++17-compat">;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits