[llvm-branch-commits] [cfe-branch] r286922 - Merging r282989:
Richard Trieu via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Nov 14 17:05:08 PST 2016
Author: rtrieu
Date: Mon Nov 14 19:05:08 2016
New Revision: 286922
URL: http://llvm.org/viewvc/llvm-project?rev=286922&view=rev
Log:
Merging r282989:
------------------------------------------------------------------------
r282989 | rtrieu | 2016-09-30 17:15:24 -0700 (Fri, 30 Sep 2016) | 10 lines
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/branches/release_39/include/clang/Basic/DiagnosticSemaKinds.td
cfe/branches/release_39/test/SemaCXX/cxx0x-defaulted-functions.cpp
Modified: cfe/branches/release_39/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/include/clang/Basic/DiagnosticSemaKinds.td?rev=286922&r1=286921&r2=286922&view=diff
==============================================================================
--- cfe/branches/release_39/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/branches/release_39/include/clang/Basic/DiagnosticSemaKinds.td Mon Nov 14 19:05:08 2016
@@ -4291,7 +4291,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/branches/release_39/test/SemaCXX/cxx0x-defaulted-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/SemaCXX/cxx0x-defaulted-functions.cpp?rev=286922&r1=286921&r2=286922&view=diff
==============================================================================
--- cfe/branches/release_39/test/SemaCXX/cxx0x-defaulted-functions.cpp (original)
+++ cfe/branches/release_39/test/SemaCXX/cxx0x-defaulted-functions.cpp Mon Nov 14 19:05:08 2016
@@ -208,3 +208,38 @@ int fn() {
t = true;
}
}
+
+namespace dependent_classes {
+template <bool B, typename X, typename Y>
+struct conditional;
+
+template <typename X, typename Y>
+struct conditional<true, X, Y> { typedef X type; };
+
+template <typename X, typename Y>
+struct conditional<false, X, Y> { typedef Y type; };
+
+template<bool B> struct X {
+ X();
+
+ // B == false triggers error for = default.
+ using T = typename conditional<B, const X &, int>::type;
+ X(T) = default; // expected-error {{only special member functions}}
+
+ // Either value of B creates a constructor that can be default
+ using U = typename conditional<B, X&&, const X&>::type;
+ X(U) = default;
+};
+
+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}}
+
+}
More information about the llvm-branch-commits
mailing list