Description
Description
In an unnamed macro having:
{
gROOT->ProcessLine(statement_1);
statement_2;
}
is process line by line (per se) and statement_2
should (and does in most case) be able to use declaration made in statement_1
. In some circumstances it does not. One such circumstance is the test roottest-cling-return-constRetrunTest_WILL_FAIL
which should actually succeed (the original problem is fixed by moving to Cling
) but still fails (unexpectedly) with:
Processing run.C...
/Users/pcanal/root_working/code/master/roottest/cling/return/./run.C:7:1: error: unknown type name 't02'
t02 t;
^
Reproducer
With the files in trun.tar.gz
we can set that the declaration in the ProcessLine
are properly seen in the next lines. For example this version of trun.C
:
{
gROOT->ProcessLine(".L t1.C");
gROOT->ProcessLine(".L t2.C");
int i123 = t_1;
int j123 = t_2;
}
works fine. Note that issuing on the prompt right after the .x trun.C
the command gROOT->SetDirLevel(t_1);
or i123 = t_2;
works as well.
But this version:
{
gROOT->ProcessLine(".L t1.C");
gROOT->ProcessLine(".L t2.C");
int i123 = t_1;
int j123 = t_2;
gROOT->SetDirLevel(t_1);
}
mysteriously fails with:
Processing trun.C...
/Users/pcanal/root_working/code/master/roottest/cling/return/./trun.C:7:1: error: cannot initialize an array element of type 'void *' with an rvalue of type 'TROOT *(*)()'
gROOT->SetDirLevel(t_1);
^~~~~
/Users/pcanal/root_working/builds/master-pr/include/TROOT.h:407:16: note: expanded from macro 'gROOT'
#define gROOT (ROOT::GetROOT())
^~~~~~~~~~~~~
The error seems to indicate that the parser is 'prefixing' to gROOT
something related to array of void*
and initialization
Similarly
{
gROOT->ProcessLine(".L t1.C");
gROOT->ProcessLine(".L t2.C");
int i123 = t_1;
int j123 = t_2;
i123 = t_2;
}
fails with:
Processing trun.C...
Assertion failed: (Node->getDependence() == ExprDependence::None), function VisitBinaryOperator, file DynamicLookup.cpp, line 628.
Abort trap: 6
And weirdly:
{
gROOT->ProcessLine(".L t1.C");
gROOT->ProcessLine(".L t2.C");
int i123 = t_1;
int j123 = t_2;
t_1 = 3;
}
fails with:
/Users/pcanal/root_working/code/master/roottest/cling/return/./trun.C:7:1: warning: declaration without the 'auto' keyword is deprecated: function '__cling_Un1Qu30' [-Wdeprecated-declarations]
t_1 = 3;
^~~
auto
input_line_11:2:3: error: reference to 't_1' is ambiguous
(t_1)
^
/Users/pcanal/root_working/code/master/roottest/cling/return/t1.C:1:5: note: candidate found by name lookup is 't_1'
int t_1 = 3;
^
/Users/pcanal/root_working/code/master/roottest/cling/return/./trun.C:7:1: note: candidate found by name lookup is '__cling_N50::t_1'
t_1 = 3;
^
input_line_11:2:3: error: unknown type name 't_1'
(t_1)
^