Clang error: cannot catch incomplete type A (err_catch_incomplete)
		
		
		
		
		
		Jump to navigation
		Jump to search
		
		
	
| Text | error: cannot catch incomplete type A | 
|---|---|
| Type | Error | 
| Category | Semantic Issue | 
| Internal Id | err_catch_incomplete | 
| Internal Message | cannot catch incomplete type %0 | 
| Regular Expression | (?:error|fatal error)\: cannot catch incomplete 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; // Incomplete type declaration
void f() {
  try {
    // some code
  } catch (S) { // catching incomplete type
    // handler code
  }
}
 | |
| Compiler Output | <source>:6:13: error: cannot catch incomplete type 'S' <source>:1:8: note: forward declaration of 'S' | 
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 16633)
/// Perform semantic analysis for the variable declaration that
/// occurs within a C++ catch clause, returning the newly-created
/// variable.
VarDecl *Sema::BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation Loc, IdentifierInfo *Name) {
  // ...
  unsigned DK = diag::err_catch_incomplete;
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/SemaCXX/exceptions.cpp
- clang/test/SemaCXX/exceptions.cpp:15:16: error: cannot catch incomplete type 'void'
- clang/test/SemaCXX/exceptions.cpp:16:13: error: cannot catch incomplete type 'A'