Skip to content

Commit 0d92eae

Browse files
committed
Use TemplatedDecl.Parameters cuz Class.TemplateParameters may not be available at this point
1 parent 06d311d commit 0d92eae

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/Generator/Generators/C/CppTypePrinter.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using CppSharp.AST;
66
using CppSharp.AST.Extensions;
77
using CppSharp.Generators.CSharp;
8+
using CppSharp.Passes;
89
using CppSharp.Types;
910

1011
namespace CppSharp.Generators.C
@@ -577,11 +578,11 @@ public override TypePrinterResult VisitClassTemplateSpecializationDecl(
577578
args.Add(arg.Declaration.Visit(this));
578579
break;
579580
case TemplateArgument.ArgumentKind.Integral:
580-
Class template = specialization.TemplatedDecl.TemplatedClass;
581-
var nonTypeTemplateParameter = template.TemplateParameters[i]
581+
ClassTemplate template = specialization.TemplatedDecl;
582+
var nonTypeTemplateParameter = template.Parameters[i]
582583
as NonTypeTemplateParameter;
583584
if (!(nonTypeTemplateParameter?.DefaultArgument is
584-
BuiltinTypeExpressionObsolete builtinExpression) ||
585+
BuiltinTypeExpressionObsolete builtinExpression) ||
585586
builtinExpression.Value != arg.Integral)
586587
{
587588
args.Add(arg.Integral.ToString(CultureInfo.InvariantCulture));

tests/CSharp/CSharpTemplates.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,3 +944,22 @@ class DLL_API FloatArrayF
944944

945945
};
946946
const FloatArrayF<6> I6{ 1., 1., 1., 0., 0., 0. };
947+
948+
// KEEP ORDER OTHERWISE TEST WONT WORK
949+
namespace IncompleteClassTemplatesTests
950+
{
951+
template <size_t Size>
952+
struct StructSizeT {};
953+
954+
template <typename T>
955+
struct StructT
956+
{
957+
template<typename U>
958+
struct Inc { };
959+
};
960+
961+
struct Instantiation
962+
{
963+
StructT<StructSizeT<4000>> st;
964+
};
965+
}

0 commit comments

Comments
 (0)