Author: rtrieu Date: Fri Sep 30 19:15:24 2016 New Revision: 282989 URL: http://llvm.org/viewvc/llvm-project?rev=282989&view=rev Log: Fix crash when emitting error.
With templated classes, is possible to not be able to determine is a member function is a special member function before the class is instantiated. Only these special member functions can be defaulted. In some cases, knowing whether a function is a special member function can't be determined until instantiation, so an uninstantiated function could possibly be defaulted too. Add a case to the error diagnostic when the function marked with a default is not known to be a special member function. Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=282989&r1=282988&r2=282989&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep 30 19:15:24 2016 @@ -4357,7 +4357,7 @@ def err_definition_of_implicitly_declare def err_definition_of_explicitly_defaulted_member : Error< "definition of explicitly defaulted %select{default constructor|copy " "constructor|move constructor|copy assignment operator|move assignment " - "operator|destructor}0">; + "operator|destructor|function}0">; def err_redefinition_extern_inline : Error< "redefinition of a 'extern inline' function %0 is not supported in " "%select{C99 mode|C++}1">; Modified: cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp?rev=282989&r1=282988&r2=282989&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp (original) +++ cfe/trunk/test/SemaCXX/cxx0x-defaulted-functions.cpp Fri Sep 30 19:15:24 2016 @@ -234,4 +234,12 @@ template<bool B> struct X { X<true> x1; X<false> x2; // expected-note {{in instantiation}} +template <typename Type> +class E { + explicit E(const int &) = default; +}; + +template <typename Type> +E<Type>::E(const int&) {} // expected-error {{definition of explicitly defaulted function}} + } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits