Browse Source

Fixes parsing of K&R-style C functions with no prototypes.

Fixes issue #641.
pull/642/head
Joao Matos 9 years ago
parent
commit
b53aaae81b
  1. 30
      src/CppParser/Parser.cpp
  2. 5
      tests/Common/Common.h

30
src/CppParser/Parser.cpp

@ -1809,6 +1809,36 @@ Type* Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL, @@ -1809,6 +1809,36 @@ Type* Parser::WalkType(clang::QualType QualType, clang::TypeLoc* TL,
Ty = A;
break;
}
case clang::Type::FunctionNoProto:
{
auto FP = Type->getAs<clang::FunctionNoProtoType>();
FunctionNoProtoTypeLoc FTL;
TypeLoc RL;
TypeLoc Next;
if (TL && !TL->isNull())
{
while (!TL->isNull() && TL->getTypeLocClass() != TypeLoc::FunctionNoProto)
{
Next = TL->getNextTypeLoc();
TL = &Next;
}
if (!TL->isNull() && TL->getTypeLocClass() == TypeLoc::FunctionNoProto)
{
FTL = TL->getAs<FunctionNoProtoTypeLoc>();
RL = FTL.getReturnLoc();
}
}
auto F = new FunctionType();
F->ReturnType = GetQualifiedType(FP->getReturnType(),
WalkType(FP->getReturnType(), &RL));
F->CallingConvention = ConvertCallConv(FP->getCallConv());
Ty = F;
break;
}
case clang::Type::FunctionProto:
{
auto FP = Type->getAs<clang::FunctionProtoType>();

5
tests/Common/Common.h

@ -1088,3 +1088,8 @@ protected: @@ -1088,3 +1088,8 @@ protected:
};
void function(ProtectedEnum param);
};
struct TestsTypes
{
int(*FunctionNoProto)();
};

Loading…
Cancel
Save