Fix crash when emitting error.
authorRichard Trieu <rtrieu@google.com>
Sat, 1 Oct 2016 00:15:24 +0000 (00:15 +0000)
committerRichard Trieu <rtrieu@google.com>
Sat, 1 Oct 2016 00:15:24 +0000 (00:15 +0000)
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

include/clang/Basic/DiagnosticSemaKinds.td
test/SemaCXX/cxx0x-defaulted-functions.cpp

index eb8bf915e8540f5f4fc0f33b56f3c65ded2e77f2..cd032b4a87bc8c14c52aa160dc2d34c508e4493d 100644 (file)
@@ -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">;
index 08d5dbd285d420dcfbd16f1d48015b501fcae6e3..7ec9726095cba79d4673c292896778e1c1a6532c 100644 (file)
@@ -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}}
+
 }