Fix compiler warning -Wimplicit-fallthrough
ClosedPublic

Authored by dhaumann on Jul 31 2018, 7:26 PM.

Details

Summary

syntax-highlighting/src/lib/definition.cpp: In member function ‘void KSyntaxHighlighting::DefinitionData::loadGeneral(QXmlStreamReader&)’:
syntax-highlighting/src/lib/definition.cpp:523:17: warning: this statement may fall through [-Wimplicit-fallthrough=]

if (elementRefCounter == 0)
^~

syntax-highlighting/src/lib/definition.cpp:525:13: note: here

default:
^~~~~~~

syntax-highlighting/src/lib/definition.cpp: In member function ‘void KSyntaxHighlighting::DefinitionData::loadFoldingIgnoreList(QXmlStreamReader&)’:
syntax-highlighting/src/lib/definition.cpp:552:17: warning: this statement may fall through [-Wimplicit-fallthrough=]

if (elementRefCounter == 0)
^~

syntax-highlighting/src/lib/definition.cpp:554:13: note: here

default:
^~~~~~~
Test Plan

make && make test

Diff Detail

Repository
R216 Syntax Highlighting
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dhaumann created this revision.Jul 31 2018, 7:26 PM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptJul 31 2018, 7:26 PM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
dhaumann requested review of this revision.Jul 31 2018, 7:26 PM

If there is a better / more readable fix, please let me know.

vkrause accepted this revision.Jul 31 2018, 7:28 PM
This revision is now accepted and ready to land.Jul 31 2018, 7:28 PM
This revision was automatically updated to reflect the committed changes.
aacid added a subscriber: aacid.Jul 31 2018, 8:53 PM

Maybe it makes more sense to replace it with the magic words?

// fall-through

agree that Q_FALLTHROUGH(); is a better idea.
it doesn't duplicate code and it informs the reader that the fallthrough is intentional

Thanks for the info - I will look into this again later.

I can see that it's code duplication, but strictly speaking the case statement of StartElement and EndElement are now more "symmetric".