Skip to content

Fix code generation for union inside struct #132

@yuhc

Description

@yuhc

See PR 131.

typedef struct {
    union Algorithm {
        cudnnConvolutionFwdAlgo_t convFwdAlgo;
        cudnnConvolutionBwdFilterAlgo_t convBwdFilterAlgo;
        cudnnConvolutionBwdDataAlgo_t convBwdDataAlgo;
        cudnnRNNAlgo_t RNNAlgo;
        cudnnCTCLossAlgo_t CTCLossAlgo;
    } algo;
} cudnnAlgorithm_t;

The generated code is like:

            cudnnAlgorithm_t *ava_self;                                                                                                                                                                                                                                    
            ava_self = (cudnnAlgorithm_t *) (&algorithm);                                                                                                                                                                                                                  
            union Algorithm *__algorithm_a_0_algo;                                                                                                                                                                                                                         
            __algorithm_a_0_algo = (union Algorithm *)(&(algorithm).algo);                                                                                                                                                                                                 
            union Algorithm *__algorithm_b_0_algo;                                                                                                                                                                                                                         
            __algorithm_b_0_algo = (union Algorithm *)(&(__call->algorithm).algo); {                                                                                                                                                                                       
                union Algorithm *ava_self;                                                                                                                                                                                                                                 
                ava_self = (union Algorithm *)(&*__algorithm_a_0_algo);                                                                                                                                                                                                    
                cudnnCTCLossAlgo_t *__algorithm_a_1_CTCLossAlgo;                                                                                                                                                                                                           
                __algorithm_a_1_CTCLossAlgo = (cudnnCTCLossAlgo_t *) (&(*__algorithm_a_0_algo).CTCLossAlgo);                                                                                                                                                               
                cudnnCTCLossAlgo_t *__algorithm_b_1_CTCLossAlgo;                                                                                                                                                                                                           
                __algorithm_b_1_CTCLossAlgo = (cudnnCTCLossAlgo_t *) (&(*__algorithm_b_0_algo).CTCLossAlgo); {                                                                                                                                                             
                    *__algorithm_a_1_CTCLossAlgo = (cudnnCTCLossAlgo_t) * __algorithm_b_1_CTCLossAlgo;                                                                                                                                                                     
                    *__algorithm_a_1_CTCLossAlgo = *__algorithm_b_1_CTCLossAlgo;                                                                                                                                                                                           
                }
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions