Clang error: conversion function cannot convert to a function type (err_conv_function_to_function)
Jump to navigation
Jump to search
Text | error: conversion function cannot convert to a function type |
---|---|
Type | Error |
Category | Semantic Issue |
Internal Id | err_conv_function_to_function |
Internal Message | conversion function cannot convert to a function type
|
Regular Expression | (?:error|fatal error)\: conversion function cannot convert to a function type
|
First Commit | 2009-03-14 5a8987ca5113 Update tablegen diagnostic files to be in sync with the def files. |
Description
Example
Flags | -xc++ -std=c++17
|
|
---|---|---|
Source |
struct S {
// Conversion to function type not allowed
operator void(*)() {};
};
| |
Compiler Output |
<source>:3:18: error: a type specifier is required for all declarations <source>:3:3: error: conversion function cannot have any parameters <source>:3:19: error: cannot specify any part of a return type in the declaration of a conversion function; use a typedef to declare a conversion to 'void ()' <source>:3:3: error: conversion function cannot convert to a function type |
Clang Internals (17.0.6)
Git Commit Message
Update tablegen diagnostic files to be in sync with the def files. llvm-svn: 67004
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 11123)
/// CheckConversionDeclarator - Called by ActOnDeclarator to check the
/// well-formednes of the conversion function declarator @p D with
/// type @p R. If there are any errors in the declarator, this routine
/// will emit diagnostics and return true. Otherwise, it will return
/// false. Either way, the type @p R will be updated to reflect a
/// well-formed type for the conversion operator.
void Sema::CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC) {
// ...
// C++ [class.conv.fct]p4:
// The conversion-type-id shall not represent a function type nor
// an array type.
if (ConvType->isArrayType()) {
// ...
} else if (ConvType->isFunctionType()) {
Diag(D.getIdentifierLoc(), diag::err_conv_function_to_function);
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/SemaCXX/PR31422.cpp
- clang/test/SemaCXX/PR31422.cpp:6:29: error: conversion function cannot convert to a function type