Skip to content

Commit

Permalink
[core] Fix statements at global scope in TCling test
Browse files Browse the repository at this point in the history
`TInterpreter::Declare` does not support issuing statements on the global scope, while `TInterpreter::ProcessLine` does. This test was first introduced in a development version of ROOT (6.31), where the upgrade to LLVM16 was already in place. In that scenario, clang supports global scope statements (thanks to changes made for clang-repl). Applying the test to ROOT 6.30 uncovered the problem, since the clang of LLVM13 does not support global scope statements. Fix the test by using `ProcessLine` instead of `Declare` which does the intended thing independently from the ROOT version.

Co-authored-by: Vassil Vassilev <vasil.georgiev.vasilev@cern.ch>
  • Loading branch information
vepadulano and vgvassilev committed Jan 25, 2024
1 parent 88c66eb commit 102a820
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions core/metacling/test/TClingDataMemberInfoTests.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,19 @@ class Outer {

TEST(TClingDataMemberInfo, Offset)
{
gInterpreter->Declare("int ROOT_7459 = 42; ROOT_7459++;");
gInterpreter->ProcessLine("int ROOT_7459 = 42; ROOT_7459++;");
EXPECT_TRUE(43 == *(int*)gROOT->GetGlobal("ROOT_7459")->GetAddress());

gInterpreter->Declare("constexpr int var1 = 1;");
gInterpreter->ProcessLine("constexpr int var1 = 1;");
EXPECT_TRUE(1 == *(int*)gROOT->GetGlobal("var1")->GetAddress());

gInterpreter->Declare("static constexpr int var2 = -2;");
gInterpreter->ProcessLine("static constexpr int var2 = -2;");
EXPECT_TRUE(-2 == *(int*)gROOT->GetGlobal("var2")->GetAddress());

gInterpreter->Declare("const float var3 = 3.1;");
gInterpreter->ProcessLine("const float var3 = 3.1;");
EXPECT_FLOAT_EQ(3.1, *(float*)gROOT->GetGlobal("var3")->GetAddress());

gInterpreter->Declare("static const double var4 = 4.2;");
gInterpreter->ProcessLine("static const double var4 = 4.2;");
EXPECT_DOUBLE_EQ(4.2, *(double*)gROOT->GetGlobal("var4")->GetAddress());

// Make sure ROOT's Core constexpr constants work
Expand Down

0 comments on commit 102a820

Please sign in to comment.