Clang error: typename specifier refers to non-type member A in B (err_typename_nested_not_type)
Jump to navigation
Jump to search
Text | error: typename specifier refers to non-type member A in B |
---|---|
Type | Error |
Category | Semantic Issue |
Internal Id | err_typename_nested_not_type |
Internal Message | typename specifier refers to non-type member %0 in %1
|
Regular Expression | (?:error|fatal error)\: typename specifier refers to non\-type member (.*?) in (.*?)
|
First Commit | 2009-03-28 333489bba35d Initial implementation of parsing, semantic analysis, and template |
Description
Example
Flags | -xc++
|
|
---|---|---|
Source |
struct S { int x; }; // S has a non-type member x
struct T { typename S::x y; }; // Error: 'x' is a non-type member
| |
Compiler Output |
<source>:2:24: error: typename specifier refers to non-type member 'x' in 'S' <source>:1:16: note: referenced member 'x' is declared here |
Clang Internals (17.0.6)
Git Commit Message
Initial implementation of parsing, semantic analysis, and template instantiation for C++ typename-specifiers such as typename T::type The parsing of typename-specifiers is relatively easy thanks to annotation tokens. When we see the "typename", we parse the typename-specifier and produce a typename annotation token. There are only a few places where we need to handle this. We currently parse the typename-specifier form that terminates in an identifier, but not the simple-template-id form, e.g., typename T::template apply<U, V> Parsing of nested-name-specifiers has a similar problem, since at this point we don't have any representation of a class template specialization whose template-name is unknown. Semantic analysis is only partially complete, with some support for template instantiation that works for simple examples. llvm-svn: 67875
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/SemaTemplate.cpp (line 11144)
/// Build the type that describes a C++ typename specifier,
/// e.g., "typename T::type".
QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, bool DeducedTSTContext) {
// ...
case LookupResult::Found:
// ...
DiagID = Ctx ? diag::err_typename_nested_not_type : diag::err_typename_not_type;
clang/lib/Sema/SemaTemplate.cpp (line 11150)
/// Build the type that describes a C++ typename specifier,
/// e.g., "typename T::type".
QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, bool DeducedTSTContext) {
// ...
case LookupResult::FoundOverloaded:
DiagID = Ctx ? diag::err_typename_nested_not_type : diag::err_typename_not_type;
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/CXX/expr/expr.prim/expr.prim.req/type-requirement.cpp
- clang/test/CXX/expr/expr.prim/expr.prim.req/type-requirement.cpp:62:51: error: typename specifier refers to non-type member 'type' in 'D'