Clang error: redeclaration of deduction guide (err_deduction_guide_redeclared)
Jump to navigation
Jump to search
Text | error: redeclaration of deduction guide (since 9.0) |
---|---|
Type | Error |
Category | Semantic Issue (since 9.0) |
Internal Id | err_deduction_guide_redeclared (since 9.0) |
Internal Message | redeclaration of deduction guide (since 9.0)
|
Regular Expression | (?:error|fatal error)\: redeclaration of deduction guide
|
First Commit | 2019-05-04 5fe2ddbdf47d [clang] adding explicit(bool) from c++2a |
Description
Example
Flags | -xc++
|
|
---|---|---|
Source |
// Deduction guide redeclared
template <class T>
struct S {
S(T);
};
template <class T>
S(T) -> S<T>;
template <class T>
S(T) -> S<T>; // Error Here
| |
Compiler Output |
<source>:12:1: error: redeclaration of deduction guide <source>:9:1: note: previous declaration is here |
Clang Internals (17.0.6)
Git Commit Message
[clang] adding explicit(bool) from c++2a this patch adds support for the explicit bool specifier. Changes: - The parsing for the explicit(bool) specifier was added in ParseDecl.cpp. - The storage of the explicit specifier was changed. the explicit specifier was stored as a boolean value in the FunctionDeclBitfields and in the DeclSpec class. now it is stored as a PointerIntPair<Expr*, 2> with a flag and a potential expression in CXXConstructorDecl, CXXDeductionGuideDecl, CXXConversionDecl and in the DeclSpec class. - Following the AST change, Serialization, ASTMatchers, ASTComparator and ASTPrinter were adapted. - Template instantiation was adapted to instantiate the potential expressions of the explicit(bool) specifier When instantiating their associated declaration. - The Add*Candidate functions were adapted, they now take a Boolean indicating if the context allowing explicit constructor or conversion function and this boolean is used to remove invalid overloads that required template instantiation to be detected. - Test for Semantic and Serialization were added. This patch is not yet complete. I still need to check that interaction with CTAD and deduction guides is correct. and add more tests for AST operations. But I wanted first feedback. Perhaps this patch should be spited in smaller patches, but making each patch testable as a standalone may be tricky. Patch by Tyker Differential Revision: https://reviews.llvm.org/D60934 llvm-svn: 359949
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 697)
/// MergeCXXFunctionDecl - Merge two declarations of the same C++
/// function, once we already know that they have the same
/// type. Subroutine of MergeFunctionDecl. Returns true if there was an
/// error, false otherwise.
bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S) {
// ...
// C++17 [temp.deduct.guide]p3:
// Two deduction guide declarations in the same translation unit
// for the same class template shall not have equivalent
// parameter-declaration-clauses.
if (isa<CXXDeductionGuideDecl>(New) && !New->isFunctionTemplateSpecialization() && isVisible(Old)) {
Diag(New->getLocation(), diag::err_deduction_guide_redeclared);
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/CXX/temp/temp.deduct.guide/p3.cpp
- clang/test/CXX/temp/temp.deduct.guide/p3.cpp:9:1: error: redeclaration of deduction guide
- clang/test/CXX/temp/temp.deduct.guide/p3.cpp:12:1: error: redeclaration of deduction guide