@@ -32,6 +32,45 @@ distribution.
3232# include < cstdarg>
3333#endif
3434
35+ // Handle fallthrough attribute for different compilers
36+ #ifndef __has_attribute
37+ # define __has_attribute (x ) 0
38+ #endif
39+ #ifdef __cplusplus
40+ # ifndef __has_cpp_attribute
41+ # define __has_cpp_attribute (x ) 0
42+ # endif
43+ #else
44+ # ifndef __has_c_attribute
45+ # define __has_c_attribute (x ) 0
46+ # endif
47+ #endif
48+
49+ #ifdef __cplusplus
50+ # if defined(_MSC_VER)
51+ # define TIXML_FALLTHROUGH (void (0 ))
52+ # elif (__cplusplus >= 201703L && __has_cpp_attribute(fallthrough))
53+ # define TIXML_FALLTHROUGH [[fallthrough]]
54+ # elif __has_cpp_attribute(clang::fallthrough)
55+ # define TIXML_FALLTHROUGH [[clang::fallthrough]]
56+ # elif __has_attribute(fallthrough)
57+ # define TIXML_FALLTHROUGH __attribute__ ((fallthrough))
58+ # else
59+ # define TIXML_FALLTHROUGH (void (0 ))
60+ # endif
61+ #else
62+ # if defined(_MSC_VER)
63+ # define TIXML_FALLTHROUGH (void (0 ))
64+ # elif __has_c_attribute(fallthrough)
65+ # define TIXML_FALLTHROUGH [[fallthrough]]
66+ # elif __has_attribute(fallthrough)
67+ # define TIXML_FALLTHROUGH __attribute__ ((fallthrough))
68+ # else
69+ # define TIXML_FALLTHROUGH (void (0 ))
70+ # endif
71+ #endif
72+
73+
3574#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) && (!defined WINCE)
3675 // Microsoft Visual Studio, version 2005 and higher. Not WinCE.
3776 /* int _snprintf_s(
@@ -446,17 +485,17 @@ void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length
446485 --output;
447486 *output = static_cast <char >((input | BYTE_MARK) & BYTE_MASK);
448487 input >>= 6 ;
449- // fall through
488+ TIXML_FALLTHROUGH;
450489 case 3 :
451490 --output;
452491 *output = static_cast <char >((input | BYTE_MARK) & BYTE_MASK);
453492 input >>= 6 ;
454- // fall through
493+ TIXML_FALLTHROUGH;
455494 case 2 :
456495 --output;
457496 *output = static_cast <char >((input | BYTE_MARK) & BYTE_MASK);
458497 input >>= 6 ;
459- // fall through
498+ TIXML_FALLTHROUGH;
460499 case 1 :
461500 --output;
462501 *output = static_cast <char >(input | FIRST_BYTE_MARK[*length]);
0 commit comments