Browse Source

Add missing `Variable.Type` null check. (#1430)

Work around an unhandled case of the type of a variable
pull/1298/head
josetr 5 years ago committed by GitHub
parent
commit
0f498a1090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/AST/ASTVisitor.cs
  2. 14
      tests/CSharp/CSharp.h

5
src/AST/ASTVisitor.cs

@ -470,6 +470,11 @@ namespace CppSharp.AST @@ -470,6 +470,11 @@ namespace CppSharp.AST
if (!VisitDeclaration(variable))
return false;
// TODO: Remove this null check once CppParser can properly handle auto types.
// This is workaround for https://github.com/mono/CppSharp/issues/1412.
if (variable.Type == null)
return false;
return variable.Type.Visit(this, variable.QualifiedType.Qualifiers);
}

14
tests/CSharp/CSharp.h

@ -1429,4 +1429,16 @@ namespace CXXRecordDeclWithoutDefinition @@ -1429,4 +1429,16 @@ namespace CXXRecordDeclWithoutDefinition
template <> struct it<list<>> { };
template <> struct it<list<> const> { };
}
}
template<int... n>
struct TestVariableWithoutType
{
template<typename... Args>
static constexpr int create(Args... args)
{
return {};
}
static constexpr auto variable = create(n...);
};

Loading…
Cancel
Save