Clang error: conversion function cannot have a return type (err_conv_function_return_type)
Jump to navigation
Jump to search
Text | error: conversion function cannot have a return type |
---|---|
Type | Error |
Category | Semantic Issue |
Internal Id | err_conv_function_return_type |
Internal Message | conversion function cannot have a return type
|
Regular Expression | (?:error|fatal error)\: conversion function cannot have a return type
|
First Commit | 2009-03-14 5a8987ca5113 Update tablegen diagnostic files to be in sync with the def files. |
Description
Example
Flags | -xc++
|
|
---|---|---|
Source |
struct S {
// Invalid conversion function
int operator int() const { return 0; }
};
| |
Compiler Output |
<source>:3:7: error: conversion function cannot have a return 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 11010)
/// 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) {
// ...
if (DS.hasTypeSpecifier() && !D.isInvalidType()) {
// ...
Diag(D.getIdentifierLoc(), diag::err_conv_function_return_type) << SourceRange(DS.getTypeSpecTypeLoc()) << SourceRange(D.getIdentifierLoc());
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/SemaCXX/conversion-function.cpp
- clang/test/SemaCXX/conversion-function.cpp:31:8: error: conversion function cannot have a return type