diff options
author | Richard Trieu <rtrieu@google.com> | 2016-10-01 00:15:24 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2016-10-01 00:15:24 +0000 |
commit | c2265be1860bf8c44e6d867485452fcdb8e7e8ae (patch) | |
tree | 2a1bf3df84cae57035c1ec75145abcbb6b48fc6e | |
parent | 6610b01a278198fecf79503c1761eabbf60d56f2 (diff) | |
download | bcm5719-llvm-c2265be1860bf8c44e6d867485452fcdb8e7e8ae.tar.gz bcm5719-llvm-c2265be1860bf8c44e6d867485452fcdb8e7e8ae.zip |
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.
llvm-svn: 282989
-rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/cxx0x-defaulted-functions.cpp | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index eb8bf915e85..cd032b4a87b 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/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/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp b/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp index 08d5dbd285d..7ec9726095c 100644 --- a/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp +++ b/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp @@ -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}} + } |