[Rose-public] Building a variable declaration

Liao, Chunhua "Leo" liao6 at llnl.gov
Tue Mar 31 07:50:57 PDT 2015


buildXXX will only build the statement.
You have to insert the newly built statement into AST.
Check SageInterface namespace for a set of insertX() functions.

Leo
On 3/30/15 9:14 PM, Tim wrote:
> Hello Dan,
> hello rose mailing list,
>
> please find attached my */minimal/* example of creating a new variable 
> declaration.
> In the example I try to create a variable declaration via this 
> function call:
>
> /    SgVariableDeclaration *var_decl = 
> SageBuilder::buildVariableDeclaration(//
> //        "my_var", SageBuilder::buildIntType(), NULL, 
> (*stmt_iter)->get_scope());/
>
> Afterwards, I try to unparse the variable declaration and receive this 
> error:
>
>     /Note: found IR node where parent was not set = 0x7fc48caa62a0 =
>     SgVariableDeclaration (may not be required) //
>     //Inside of Sg_File_Info::display(Location of problematic IR node)
>     of this pointer = 0x1291468 //
>     //     isTransformation                      = true (part of a
>     transformation) //
>     //     isCompilerGenerated                   = false //
>     //     isOutputInCodeGeneration              = true (output in
>     code generator) //
>     //     isShared                              = false //
>     //     isFrontendSpecific                    = false //
>     //     isSourcePositionUnavailableInFrontend = false //
>     //     isCommentOrDirective                  = false //
>     //     isToken                               = false //
>     //     isDefaultArgument                     = false //
>     //     isImplicitCast                        = false //
>     //filename and line, column info should be invalid for
>     transformation or compiler generated objects//
>     //we print their values anyway for your reference//
>     //     filename = transformation //
>     //     line     = 0  column = 0 //
>     //     physical_file_id       = -3 = transformation //
>     //     physical_line          = 0 //
>     //     source_sequence_number = 0 //
>     //Error: NULL parent pointer not allowed for statement =
>     0x7fc48caa62a0 = SgVariableDeclaration =
>     _variable_declaration_my_var //
>     //Inside of Sg_File_Info::display(Error: NULL parent pointer not
>     allowed for statement) of this pointer = 0x1291468 //
>     //     isTransformation                      = true (part of a
>     transformation) //
>     //     isCompilerGenerated                   = false //
>     //     isOutputInCodeGeneration              = true (output in
>     code generator) //
>     //     isShared                              = false //
>     //     isFrontendSpecific                    = false //
>     //     isSourcePositionUnavailableInFrontend = false //
>     //     isCommentOrDirective                  = false //
>     //     isToken                               = false //
>     //     isDefaultArgument                     = false //
>     //     isImplicitCast                        = false //
>     //filename and line, column info should be invalid for
>     transformation or compiler generated objects//
>     //we print their values anyway for your reference//
>     //     filename = transformation //
>     //     line     = 0  column = 0 //
>     //     physical_file_id       = -3 = transformation //
>     //     physical_line          = 0 //
>     //     source_sequence_number = 0 //
>     //create_var.out: Cxx_Grammar.C:91401: virtual SgScopeStatement*
>     SgStatement::get_scope() const: Assertion `stmt->get_parent() !=
>     __null' failed.//
>     //Aborted (core dumped)/
>
> Can somebody please help me out? I am stuck.
> Iam very thankful for any hint!
>
> Best regards
>
> Tim
>
>
> _______________________________________________
> rose-public mailing list
> rose-public at nersc.gov

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nersc.gov/pipermail/rose-public/attachments/20150331/e83c0ea9/attachment.html>


More information about the rose-public mailing list