lefticus / decent_ci

18 stars 4 forks source link

Improve unused variable compiler warning #10

Open Myoldmopar opened 8 years ago

Myoldmopar commented 8 years ago

Background: Compile this commit on Ubuntu: https://github.com/NREL/EnergyPlus/commit/253e757bf8b3045b1c379dc93a297a6988cb9f28. CI will report this:

image

If you follow that link, it takes you to the header declaration of ManageElectricPower::ElecStorage. Actually, that warning is because the variable is being brought into the local namespace here, and then not used within that function.

If you compile it locally, the compiler actually gives the full function name where the variable is brought in using the using statement, so it is easy to find. The error message that CI reports isn't too useful. Especially since Ubuntu is currently the only platform that reports these, so @myoldmopar ends up having to run the build locally to help diagnose the issue.

Myoldmopar commented 8 years ago

More detailed information about the error.

GCC can sometimes give warnings about unused "variables", when they are actually unused variables imported into the namespace using "using". The CI doesn't give much useful information as it only processes the last bit of the warning message. Take the following example:

In PlantValves.cc, in the init() function, there is a line:

   using DataHVACGlobals::NumPlantLoops;

This variable never gets used. The message coming out of the compiler is:

In file included from /home/elee/eplus/EnergyPlus/src/EnergyPlus/PlantValves.cc:69:0:
/home/elee/eplus/EnergyPlus/src/EnergyPlus/DataHVACGlobals.hh: In member function ‘void EnergyPlus::PlantValves::TemperValveData::init()’:
/home/elee/eplus/EnergyPlus/src/EnergyPlus/DataHVACGlobals.hh:325:13: warning: unused variable ‘EnergyPlus::DataHVACGlobals::NumPlantLoops’ [-Wunused-variable]
  extern int NumPlantLoops; // Number of plant loops specified in simulation

The warning message never calls out the line number of the using statement, but it does list the function which "using"s it. This would be a helpful tip.

The CI report only captures the end of this message as shown in the image in the first comment above. This is even more of a problem now that I don't use Linux day-to-day, because I have to pull up a full build just to diagnose the unused variable location.

Is it possible to parse that error message in order to get the text: In member function ‘void EnergyPlus::PlantValves::TemperValveData::init()’:?