From: Richard Trieu Date: Sat, 1 Oct 2016 00:15:24 +0000 (+0000) Subject: Fix crash when emitting error. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eccfe90bd251e8083a3a1f43a14928b060f8301a;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282989 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index eb8bf915e8..cd032b4a87 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -4357,7 +4357,7 @@ def err_definition_of_implicitly_declared_member : Error< 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">; diff --git a/test/SemaCXX/cxx0x-defaulted-functions.cpp b/test/SemaCXX/cxx0x-defaulted-functions.cpp index 08d5dbd285..7ec9726095 100644 --- a/test/SemaCXX/cxx0x-defaulted-functions.cpp +++ b/test/SemaCXX/cxx0x-defaulted-functions.cpp @@ -234,4 +234,12 @@ template struct X { X x1; X x2; // expected-note {{in instantiation}} +template +class E { + explicit E(const int &) = default; +}; + +template +E::E(const int&) {} // expected-error {{definition of explicitly defaulted function}} + }