Clang error: exception specifications are not allowed beyond a single level of indirection (err_distant_exception_spec)
		
		
		
		
		
		Jump to navigation
		Jump to search
		
		
	
| Text | error: exception specifications are not allowed beyond a single level of indirection | 
|---|---|
| Type | Error | 
| Category | Semantic Issue | 
| Internal Id | err_distant_exception_spec | 
| Internal Message | exception specifications are not allowed beyond a single level of indirection | 
| Regular Expression | (?:error|fatal error)\: exception specifications are not allowed beyond a single level of indirection | 
| First Commit | 2009-05-29 10b9de45c376 Disallow exception specifications on multi-level indirections. | 
Description
Example
| Flags | -xc++ -std=c++11 | |
|---|---|---|
| Source | // Exception specification with two indirection levels
void f(void (**p)(void) throw(int));
 | |
| Compiler Output | <source>:2:16: error: exception specifications are not allowed beyond a single level of indirection | 
Clang Internals (17.0.6)
Git Commit Message
Disallow exception specifications on multi-level indirections. llvm-svn: 72571
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/SemaType.cpp (line 3076)
/// Build a member pointer type \c T Class::*.
///
/// \param T the type to which the member pointer refers.
/// \param Class the class type into which the member pointer points.
/// \param Loc the location where this type begins
/// \param Entity the name of the entity that will have this member pointer type
///
/// \returns a member pointer type, if successful, or a NULL type if there was
/// an error.
QualType Sema::BuildMemberPointerType(QualType T, QualType Class, SourceLocation Loc, DeclarationName Entity) {
  // Verify that we're not building a pointer to pointer to function with
  // exception specification.
  if (CheckDistantExceptionSpec(T)) {
    Diag(Loc, diag::err_distant_exception_spec);
clang/lib/Sema/SemaType.cpp (line 5053)
static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, QualType declSpecType, TypeSourceInfo *TInfo) {
  // ...
  for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) {
    // ...
    case DeclaratorChunk::Pointer:
      // Verify that we're not building a pointer to pointer to function with
      // exception specification.
      if (LangOpts.CPlusPlus && S.CheckDistantExceptionSpec(T)) {
        S.Diag(D.getIdentifierLoc(), diag::err_distant_exception_spec);
clang/lib/Sema/SemaType.cpp (line 5089)
static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, QualType declSpecType, TypeSourceInfo *TInfo) {
  // ...
  for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) {
    // ...
    case DeclaratorChunk::Reference: {
      // Verify that we're not building a reference to pointer to function with
      // exception specification.
      if (LangOpts.CPlusPlus && S.CheckDistantExceptionSpec(T)) {
        S.Diag(D.getIdentifierLoc(), diag::err_distant_exception_spec);
clang/lib/Sema/SemaType.cpp (line 5103)
static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, QualType declSpecType, TypeSourceInfo *TInfo) {
  // ...
  for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) {
    // ...
    case DeclaratorChunk::Array: {
      // Verify that we're not building an array of pointers to function with
      // exception specification.
      if (LangOpts.CPlusPlus && S.CheckDistantExceptionSpec(T)) {
        S.Diag(D.getIdentifierLoc(), diag::err_distant_exception_spec);
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/CXX/except/except.spec/p2-places.cpp
- clang/test/CXX/except/except.spec/p2-places.cpp:35:11: error: exception specifications are not allowed beyond a single level of indirection
- clang/test/CXX/except/except.spec/p2-places.cpp:38:13: error: exception specifications are not allowed beyond a single level of indirection
- clang/test/CXX/except/except.spec/p2-places.cpp:62:11: error: exception specifications are not allowed beyond a single level of indirection
- clang/test/CXX/except/except.spec/p2-places.cpp:64:13: error: exception specifications are not allowed beyond a single level of indirection