Clang error: definition of explicitly defaulted ... (err_definition_of_explicitly_defaulted_member)
Jump to navigation
Jump to search
Text |
| ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Type | Error | ||||||||||
Category | Semantic Issue | ||||||||||
Internal Id | err_definition_of_explicitly_defaulted_member | ||||||||||
Internal Message | definition of explicitly defaulted %select{default constructor|copy constructor|move constructor|copy assignment operator|move assignment operator|destructor|function}0
| ||||||||||
Regular Expression | (?:error|fatal error)\: definition of explicitly defaulted (?:default constructor|copy constructor|move constructor|copy assignment operator|move assignment operator|destructor|function)
| ||||||||||
First Commit | 2011-05-10 6d5b96c6b3ef Further implement defaulting constructors. |
Description
Example
Flags | -xc++
|
|
---|---|---|
Source |
class C {
public:
C();
~C() = default; // Explicitly defaulted
};
C::~C() {} // Error: cannot redefine
| |
Compiler Output |
<source>:6:4: error: definition of explicitly defaulted destructor |
Clang Internals (17.0.6)
Git Commit Message
Further implement defaulting constructors. Focus is on default constructors for the time being. Currently the exception specification and prototype are processed correctly. Codegen might work but in all likelihood doesn't. Note that due to an error, out-of-line defaulting of member functions is currently impossible. It will continue to that until I muster up the courage to admit that I secretly pray to epimetheus and that I need to rework the way default gets from Parse -> Sema. llvm-svn: 131115
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/Sema/SemaDecl.cpp (line 4030)
/// MergeFunctionDecl - We just parsed a function 'New' from
/// declarator D which has the same name and scope as a previous
/// declaration 'Old'. Figure out how to resolve this situation,
/// merging decls or emitting diagnostics as appropriate.
///
/// In C++, New and Old must be declarations that are not
/// overloaded. Use IsOverload to determine whether New and Old are
/// overloaded, and to select the Old declaration that New should be
/// merged with.
///
/// Returns true if there was an error, false otherwise.
bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S, bool MergeTypeWithOld, bool NewDeclIsDefn) {
// ...
if (getLangOpts().CPlusPlus) {
// ...
if (OldMethod && NewMethod) {
// ...
if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord() && !IsClassScopeExplicitSpecialization) {
// ...
} else if (OldMethod->isImplicit()) {
// ...
} else if (OldMethod->getFirstDecl()->isExplicitlyDefaulted() && !isFriend) {
Diag(NewMethod->getLocation(), diag::err_definition_of_explicitly_defaulted_member) << getSpecialMember(OldMethod);
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
- clang/test/SemaCXX/cxx0x-defaulted-functions.cpp:146:6: error: definition of explicitly defaulted default constructor
- clang/test/SemaCXX/cxx0x-defaulted-functions.cpp:147:6: error: definition of explicitly defaulted copy constructor
- clang/test/SemaCXX/cxx0x-defaulted-functions.cpp:148:6: error: definition of explicitly defaulted move constructor
- clang/test/SemaCXX/cxx0x-defaulted-functions.cpp:149:9: error: definition of explicitly defaulted copy assignment operator
- clang/test/SemaCXX/cxx0x-defaulted-functions.cpp:150:9: error: definition of explicitly defaulted move assignment operator
- clang/test/SemaCXX/cxx0x-defaulted-functions.cpp:151:6: error: definition of explicitly defaulted destructor
- clang/test/SemaCXX/cxx0x-defaulted-functions.cpp:244:10: error: definition of explicitly defaulted function