| author | |
| committer | |
| log | da54e7cd00d81be7eb77a83474a734e4ce39eb98 |
| tree | f8d83b59cde13876984536561a558fe0cc606458 |
| parent | 755c5580267b246983fc0b2b2fb8dccfc261b9a0 |
2 files changed, 13 insertions(+), 7 deletions(-)
src/clang.zig+11-4| ... | ... | @@ -408,7 +408,7 @@ pub const Expr = opaque { |
| 408 | 408 | extern fn ZigClangExpr_getBeginLoc(*const Expr) SourceLocation; |
| 409 | 409 | |
| 410 | 410 | pub const EvaluateAsConstantExpr = ZigClangExpr_EvaluateAsConstantExpr; |
| 411 | extern fn ZigClangExpr_EvaluateAsConstantExpr(*const Expr, *ExprEvalResult, Expr_ConstExprUsage, *const ASTContext) bool; | |
| 411 | extern fn ZigClangExpr_EvaluateAsConstantExpr(*const Expr, *ExprEvalResult, Expr_ConstantExprKind, *const ASTContext) bool; | |
| 412 | 412 | }; |
| 413 | 413 | |
| 414 | 414 | pub const FieldDecl = opaque { |
| ... | ... | @@ -1250,6 +1250,8 @@ pub const CK = extern enum { |
| 1250 | 1250 | IntegralCast, |
| 1251 | 1251 | IntegralToBoolean, |
| 1252 | 1252 | IntegralToFloating, |
| 1253 | FloatingToFixedPoint, | |
| 1254 | FixedPointToFloating, | |
| 1253 | 1255 | FixedPointCast, |
| 1254 | 1256 | FixedPointToIntegral, |
| 1255 | 1257 | IntegralToFixedPoint, |
| ... | ... | @@ -1356,6 +1358,7 @@ pub const DeclKind = extern enum { |
| 1356 | 1358 | MSGuid, |
| 1357 | 1359 | OMPDeclareMapper, |
| 1358 | 1360 | OMPDeclareReduction, |
| 1361 | TemplateParamObject, | |
| 1359 | 1362 | UnresolvedUsingValue, |
| 1360 | 1363 | OMPAllocate, |
| 1361 | 1364 | OMPRequires, |
| ... | ... | @@ -1466,6 +1469,8 @@ pub const BuiltinTypeKind = extern enum { |
| 1466 | 1469 | SveFloat64x4, |
| 1467 | 1470 | SveBFloat16x4, |
| 1468 | 1471 | SveBool, |
| 1472 | VectorQuad, | |
| 1473 | VectorPair, | |
| 1469 | 1474 | Void, |
| 1470 | 1475 | Bool, |
| 1471 | 1476 | Char_U, |
| ... | ... | @@ -1619,9 +1624,11 @@ pub const PreprocessedEntity_EntityKind = extern enum { |
| 1619 | 1624 | InclusionDirectiveKind, |
| 1620 | 1625 | }; |
| 1621 | 1626 | |
| 1622 | pub const Expr_ConstExprUsage = extern enum { | |
| 1623 | EvaluateForCodeGen, | |
| 1624 | EvaluateForMangling, | |
| 1627 | pub const Expr_ConstantExprKind = extern enum { | |
| 1628 | Normal, | |
| 1629 | NonClassTemplateArgument, | |
| 1630 | ClassTemplateArgument, | |
| 1631 | ImmediateInvocation, | |
| 1625 | 1632 | }; |
| 1626 | 1633 | |
| 1627 | 1634 | pub const UnaryExprOrTypeTrait_Kind = extern enum { |
src/translate_c.zig+2-3| ... | ... | @@ -2028,7 +2028,6 @@ fn transCCast( |
| 2028 | 2028 | // 1. If src_type is an enum, determine the underlying signed int type |
| 2029 | 2029 | // 2. Extend or truncate without changing signed-ness. |
| 2030 | 2030 | // 3. Bit-cast to correct signed-ness |
| 2031 | ||
| 2032 | 2031 | const src_type_is_signed = cIsSignedInteger(src_type) or cIsEnum(src_type); |
| 2033 | 2032 | const src_int_type = if (cIsInteger(src_type)) src_type else cIntTypeForEnum(src_type); |
| 2034 | 2033 | const src_int_expr = if (cIsInteger(src_type)) expr else try transEnumToInt(rp.c, expr); |
| ... | ... | @@ -2859,7 +2858,7 @@ fn transDefault( |
| 2859 | 2858 | |
| 2860 | 2859 | fn transConstantExpr(rp: RestorePoint, scope: *Scope, expr: *const clang.Expr, used: ResultUsed) TransError!*ast.Node { |
| 2861 | 2860 | var result: clang.ExprEvalResult = undefined; |
| 2862 | if (!expr.EvaluateAsConstantExpr(&result, .EvaluateForCodeGen, rp.c.clang_context)) | |
| 2861 | if (!expr.EvaluateAsConstantExpr(&result, .Normal, rp.c.clang_context)) | |
| 2863 | 2862 | return revertAndWarn(rp, error.UnsupportedTranslation, expr.getBeginLoc(), "invalid constant expression", .{}); |
| 2864 | 2863 | |
| 2865 | 2864 | var val_node: ?*ast.Node = null; |
| ... | ... | @@ -5881,7 +5880,7 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!* |
| 5881 | 5880 | return error.ParseError; |
| 5882 | 5881 | } |
| 5883 | 5882 | |
| 5884 | const ident_token = try appendTokenFmt(c, .Identifier, "{}_{}", .{slice, m.slice()}); | |
| 5883 | const ident_token = try appendTokenFmt(c, .Identifier, "{}_{}", .{ slice, m.slice() }); | |
| 5885 | 5884 | const identifier = try c.arena.create(ast.Node.OneToken); |
| 5886 | 5885 | identifier.* = .{ |
| 5887 | 5886 | .base = .{ .tag = .Identifier }, |