Clang warning: delegating constructors are incompatible with C++98 [-Wc++98-compat] (warn_cxx98_compat_delegating_ctor)
Jump to navigation
Jump to search
Text | error: delegating constructors are incompatible with C++98 |
---|---|
Type | Warning |
Category | Semantic Issue |
Internal Id | warn_cxx98_compat_delegating_ctor |
Active by Default | No |
Flags | -Wc++98-compat (131 elements) -Wc++98-compat-pedantic (217 elements) |
Internal Message | delegating constructors are incompatible with C++98
|
Regular Expression | (?:warning|error|fatal error)\: delegating constructors are incompatible with C\+\+98 \[(?:\-Werror,)?\-Wc\+\+98\-compat[^\]]*\]
|
First Commit | 2011-10-18 0bf8a492fd75 -Wc++98-compat and -Wc++98-compat-pedantic warnings for Sema, part 1. |
Description
Example
Flags | -xc++ -std=c++11 -Wc++98-compat
|
|
---|---|---|
Source |
#include <iostream>
class C {
public:
C(int x) : C() { // Delegating constructor
std::cout << "Constructor with int argument: " << x << std::endl;
}
C() {
std::cout << "Default constructor" << std::endl;
}
};
int main() {
C o(10);
return 0;
}
| |
Compiler Output |
<source>:5:16: warning: delegating constructors are incompatible with C++98 [-Wc++98-compat] |
Clang Internals (17.0.6)
Git Commit Message
-Wc++98-compat and -Wc++98-compat-pedantic warnings for Sema, part 1. llvm-svn: 142419
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/SemaDeclCXX.cpp (line 4621)
MemInitResult Sema::BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl) {
// ...
Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/SemaCXX/cxx98-compat.cpp
- clang/test/SemaCXX/cxx98-compat.cpp:170:20: warning: delegating constructors are incompatible with C++98 [-Wc++98-compat]