Skip to content

Commit

Permalink
Properly skip EnumForwardDecls even with attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd committed Dec 9, 2024
1 parent c51d82a commit bfb5167
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/generator/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -635,20 +635,17 @@ function (x::CodegenPreprocessing)(dag::ExprDAG, options::Dict)
dag.nodes[i] = ExprNode(node.id, skip_mode, node.cursor, node.exprs, node.adj)
show_info &&
@info "[CodegenPreprocessing]: skip a $(node.type) node named $(node.id)"
end
if attribute_check(dag, node)
elseif attribute_check(dag, node)
ty = attribute_type(node.type)
dag.nodes[i] = ExprNode(node.id, ty, node.cursor, node.exprs, node.adj)
show_info &&
@info "[CodegenPreprocessing]: mark an attribute $(node.type) node named $(node.id)"
end
if nested_anonymous_check(dag, node)
elseif nested_anonymous_check(dag, node)
ty = nested_anonymous_type(node.type)
dag.nodes[i] = ExprNode(node.id, ty, node.cursor, node.exprs, node.adj)
show_info &&
@info "[CodegenPreprocessing]: mark a nested anonymous $(node.type) node named $(node.id)"
end
if bitfield_check(dag, node)
elseif bitfield_check(dag, node)
ty = bitfield_type(node.type)
dag.nodes[i] = ExprNode(node.id, ty, node.cursor, node.exprs, node.adj)
show_info &&
Expand Down
20 changes: 20 additions & 0 deletions test/generators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,26 @@ end
@test_logs (:info, "Done!") match_mode = :any build!(ctx)
end

@testset "PR 522 - Still skip EnumForwardDecl with attributes" begin
ctx = create_context([joinpath(@__DIR__, "include/elaborateEnum.h")], get_default_args())

mktemp() do path, io
redirect_stdout(io) do
build!(ctx)
end
close(io)

output = Ref{String}("")
open(path) do file
output[] = read(file, String)
end

print(output[])
@test contains(output[],"@cenum X::UInt32 begin") # Correctly output
@test !contains(output[], "const X = UInt32") # const not output
end
end

@testset "Issue 452 - StructMutualRef" begin
ctx = create_context([joinpath(@__DIR__, "include/struct-mutual-ref.h")], get_default_args())
@test_logs (:info, "Done!") match_mode = :any build!(ctx)
Expand Down
1 change: 1 addition & 0 deletions test/include/elaborateEnum.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <stdint.h>

typedef enum __attribute__((flag_enum,enum_extensibility(open))) X : uint32_t X;
enum X : uint32_t {
A = 2,
B = 4,
Expand Down

0 comments on commit bfb5167

Please sign in to comment.