Index: ps/trunk/source/gui/CInput.cpp =================================================================== --- ps/trunk/source/gui/CInput.cpp +++ ps/trunk/source/gui/CInput.cpp @@ -295,7 +295,7 @@ } cooked = '\n'; // Change to '\n' and do default: - // NOTE: Fall-through + FALLTHROUGH; } default: // Insert a character { Index: ps/trunk/source/gui/GUItext.cpp =================================================================== --- ps/trunk/source/gui/GUItext.cpp +++ ps/trunk/source/gui/GUItext.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2017 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -327,7 +327,7 @@ LOGERROR("Parameter without value at pos %d '%s'", p, utf8_from_wstring(str)); break; } - // fall-through + FALLTHROUGH; case L'=': // parse a quoted parameter if (closing) // We still parse them to make error handling cleaner @@ -354,7 +354,7 @@ break; } // NOTE: We do not support \n in tag parameters - // fall-through + FALLTHROUGH; default: param.push_back(str[p]); } @@ -419,7 +419,7 @@ m_RawString.push_back(L'\n'); break; } - // fall-through + FALLTHROUGH; default: ++rawpos; m_RawString.push_back(str[p]); Index: ps/trunk/source/lib/code_annotation.h =================================================================== --- ps/trunk/source/lib/code_annotation.h +++ ps/trunk/source/lib/code_annotation.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (c) 2017 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -387,4 +387,16 @@ #define WIDEN2(x) L ## x #define WIDEN(x) WIDEN2(x) +// TODO: Replace this with [[fallthrough]] once we support C++17 +#if __has_cpp_attribute(fallthrough) || defined(__cplusplus) && __cplusplus >= 201703L +# define FALLTHROUGH [[fallthrough]] +#elif __has_cpp_attribute(gnu::fallthrough) +# define FALLTHROUGH [[gnu::fallthrough]] +#elif __has_cpp_attribute(clang::fallthrough) +# define FALLTHROUGH [[clang::fallthrough]] +#else +# define FALLTHROUGH +// TODO: Maybe use __fallthrough for the MSVC code analyzer (also figure out if we need to add some switch when switching to a newer version of VS that supports [[fallthrough]] +#endif + #endif // #ifndef INCLUDED_CODE_ANNOTATION Index: ps/trunk/source/lib/sysdep/compiler.h =================================================================== --- ps/trunk/source/lib/sysdep/compiler.h +++ ps/trunk/source/lib/sysdep/compiler.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (c) 2017 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -68,6 +68,10 @@ # define __has_feature(x) 0 #endif +#ifndef __has_cpp_attribute +# define __has_cpp_attribute(x) 0 +#endif + // are PreCompiled Headers supported? #if MSC_VERSION Index: ps/trunk/source/lib/sysdep/os/unix/unix.cpp =================================================================== --- ps/trunk/source/lib/sysdep/os/unix/unix.cpp +++ ps/trunk/source/lib/sysdep/os/unix/unix.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (c) 2017 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -172,7 +172,7 @@ { case 103: // Debugger udbg_launch_debugger(); - //-fallthrough + FALLTHROUGH; case 102: // Break if(manual_break) @@ -244,7 +244,7 @@ case EOF: case 'd': case 'D': udbg_launch_debugger(); - //-fallthrough + FALLTHROUGH; case 'b': case 'B': if(manual_break) Index: ps/trunk/source/ps/Preprocessor.cpp =================================================================== --- ps/trunk/source/ps/Preprocessor.cpp +++ ps/trunk/source/ps/Preprocessor.cpp @@ -771,6 +771,7 @@ { case Token::TK_EOS: Error (Line, "Unfinished list of arguments"); + FALLTHROUGH; case Token::TK_ERROR: return Token (Token::TK_ERROR); case Token::TK_PUNCTUATION: @@ -844,6 +845,7 @@ { case Token::TK_EOS: Error (Line, "Unfinished list of arguments"); + FALLTHROUGH; case Token::TK_ERROR: return Token (Token::TK_ERROR); @@ -1282,6 +1284,7 @@ empty_lines = 0; } // Fallthrough to default + FALLTHROUGH; case Token::TK_WHITESPACE: // Fallthrough to default default: Index: ps/trunk/source/renderer/TexturedLineRData.cpp =================================================================== --- ps/trunk/source/renderer/TexturedLineRData.cpp +++ ps/trunk/source/renderer/TexturedLineRData.cpp @@ -352,7 +352,7 @@ radius *= 1.5f; // make it a bit sharper (note that we don't use the radius for the butt-end corner points so it should be ok) centerVertex.m_UVs[0] = 0.480f; // slight visual correction to make the texture match up better at the corner points } - // fall-through + FALLTHROUGH; case SOverlayTexturedLine::LINECAP_ROUND: { // Draw a rounded line cap in the 3D plane of the line specified by the two corner points and the normal vector of the Index: ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp =================================================================== --- ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp +++ ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp @@ -408,8 +408,8 @@ const CMessageValueModification& msgData = static_cast (msg); if (msgData.component != L"UnitMotion") break; + FALLTHROUGH; } - // fall-through case MT_OwnershipChanged: case MT_Deserialized: {