Skip to content

Commit 2a33dcc

Browse files
committed
Merge pull request #487 from krlmlr/486-noret
Annotate stop() with NORET
2 parents 2bbb1fd + d1f27e8 commit 2a33dcc

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2016-06-02 Kirill Müller <[email protected]>
2+
3+
* inst/include/Rcpp/algorithm.h: Use "long long" only if available
4+
* inst/include/Rcpp/exceptions.h: Annotate stop() with NORET
5+
16
2016-05-18 Daniel C. Dillon <[email protected]>
27

38
* inst/include/Rcpp/algorithm.h: New approach for sugar

inst/NEWS.Rd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
\itemize{
88
\item Changes in Rcpp API:
99
\itemize{
10+
\item The \code{long long} data type is used only if it is available,
11+
to avoid compiler warnings (Kirill Müller in \ghpr{488}).
12+
\item The compiler is made aware that \code{stop()} never returns, to
13+
improve code path analysis (Kirill Müller in \ghpr{487} addressing issue
14+
\ghit{486}).
1015
\item String replacement was corrected (Qiang in \ghpr{479} following
1116
mailing list bug report by Masaki Tsuda)
1217
}

inst/include/Rcpp/algorithm.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ namespace helpers {
1212
typedef struct {char a[2];} CTYPE_SHORT;
1313
typedef struct {char a[3];} CTYPE_INT;
1414
typedef struct {char a[4];} CTYPE_LONG;
15+
#ifdef RCPP_HAS_LONG_LONG_TYPES
1516
typedef struct {char a[5];} CTYPE_LONG_LONG;
17+
#endif
1618
typedef struct {char a[6];} CTYPE_FLOAT;
1719
typedef struct {char a[7];} CTYPE_DOUBLE;
1820
typedef struct {char a[8];} CTYPE_LONG_DOUBLE;
@@ -21,7 +23,9 @@ namespace helpers {
2123
typedef struct {char a[11];} CTYPE_UNSIGNED_SHORT;
2224
typedef struct {char a[12];} CTYPE_UNSIGNED_INT;
2325
typedef struct {char a[13];} CTYPE_UNSIGNED_LONG;
26+
#ifdef RCPP_HAS_LONG_LONG_TYPES
2427
typedef struct {char a[14];} CTYPE_UNSIGNED_LONG_LONG;
28+
#endif
2529
typedef struct {char a[128];} CTYPE_UNKNOWN;
2630

2731
template< std::size_t I >
@@ -39,8 +43,10 @@ namespace helpers {
3943
template<>
4044
struct ctype_helper< sizeof(CTYPE_LONG) > { typedef long type; static const bool value = true; };
4145

46+
#ifdef RCPP_HAS_LONG_LONG_TYPES
4247
template<>
4348
struct ctype_helper< sizeof(CTYPE_LONG_LONG) > { typedef long long type; static const bool value = true; };
49+
#endif
4450

4551
template<>
4652
struct ctype_helper< sizeof(CTYPE_FLOAT) > { typedef float type; static const bool value = true; };
@@ -66,8 +72,10 @@ namespace helpers {
6672
template<>
6773
struct ctype_helper< sizeof(CTYPE_UNSIGNED_LONG) > { typedef unsigned long type; static const bool value = true; };
6874

75+
#ifdef RCPP_HAS_LONG_LONG_TYPES
6976
template<>
7077
struct ctype_helper< sizeof(CTYPE_UNSIGNED_LONG_LONG) > { typedef unsigned long long type; static const bool value = true; };
78+
#endif
7179

7280

7381
template< typename T >
@@ -77,7 +85,9 @@ namespace helpers {
7785
static CTYPE_SHORT test(const short &);
7886
static CTYPE_INT test(const int &);
7987
static CTYPE_LONG test(const long &);
88+
#ifdef RCPP_HAS_LONG_LONG_TYPES
8089
static CTYPE_LONG_LONG test(const long long &);
90+
#endif
8191
static CTYPE_FLOAT test(const float &);
8292
static CTYPE_DOUBLE test(const double &);
8393
static CTYPE_LONG_DOUBLE test(const long double &);
@@ -86,7 +96,9 @@ namespace helpers {
8696
static CTYPE_UNSIGNED_SHORT test(const unsigned short &);
8797
static CTYPE_UNSIGNED_INT test(const unsigned int &);
8898
static CTYPE_UNSIGNED_LONG test(const unsigned long &);
99+
#ifdef RCPP_HAS_LONG_LONG_TYPES
89100
static CTYPE_UNSIGNED_LONG_LONG test(const unsigned long long &);
101+
#endif
90102
static CTYPE_UNKNOWN test(...);
91103

92104
static T make();
@@ -101,7 +113,9 @@ namespace helpers {
101113
static CTYPE_SHORT test(const short &);
102114
static CTYPE_INT test(const int &);
103115
static CTYPE_LONG test(const long &);
116+
#ifdef RCPP_HAS_LONG_LONG_TYPES
104117
static CTYPE_LONG_LONG test(const long long &);
118+
#endif
105119
static CTYPE_FLOAT test(const float &);
106120
static CTYPE_DOUBLE test(const double &);
107121
static CTYPE_LONG_DOUBLE test(const long double &);
@@ -110,7 +124,9 @@ namespace helpers {
110124
static CTYPE_UNSIGNED_SHORT test(const unsigned short &);
111125
static CTYPE_UNSIGNED_INT test(const unsigned int &);
112126
static CTYPE_UNSIGNED_LONG test(const unsigned long &);
127+
#ifdef RCPP_HAS_LONG_LONG_TYPES
113128
static CTYPE_UNSIGNED_LONG_LONG test(const unsigned long long &);
129+
#endif
114130
static CTYPE_UNKNOWN test(...);
115131

116132
static T make();

inst/include/Rcpp/exceptions.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,57 +247,57 @@ namespace Rcpp{
247247
Rf_warning( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10).c_str() );
248248
}
249249

250-
inline void stop(const std::string& message) {
250+
inline void NORET stop(const std::string& message) {
251251
throw Rcpp::exception(message.c_str());
252252
}
253253

254254
template <typename T1>
255-
inline void stop(const char* fmt, const T1& arg1) {
255+
inline void NORET stop(const char* fmt, const T1& arg1) {
256256
throw Rcpp::exception( tfm::format(fmt, arg1 ).c_str() );
257257
}
258258

259259
template <typename T1, typename T2>
260-
inline void stop(const char* fmt, const T1& arg1, const T2& arg2) {
260+
inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2) {
261261
throw Rcpp::exception( tfm::format(fmt, arg1, arg2 ).c_str() );
262262
}
263263

264264
template <typename T1, typename T2, typename T3>
265-
inline void stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3) {
265+
inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3) {
266266
throw Rcpp::exception( tfm::format(fmt, arg1, arg2, arg3).c_str() );
267267
}
268268

269269
template <typename T1, typename T2, typename T3, typename T4>
270-
inline void stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4) {
270+
inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4) {
271271
throw Rcpp::exception( tfm::format(fmt, arg1, arg2, arg3, arg4).c_str() );
272272
}
273273

274274
template <typename T1, typename T2, typename T3, typename T4, typename T5>
275-
inline void stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5) {
275+
inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5) {
276276
throw Rcpp::exception( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5).c_str() );
277277
}
278278

279279
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
280-
inline void stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6) {
280+
inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6) {
281281
throw Rcpp::exception( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6).c_str() );
282282
}
283283

284284
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
285-
inline void stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7) {
285+
inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7) {
286286
throw Rcpp::exception( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7).c_str() );
287287
}
288288

289289
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
290-
inline void stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8) {
290+
inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8) {
291291
throw Rcpp::exception( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8).c_str() );
292292
}
293293

294294
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
295-
inline void stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8, const T9& arg9) {
295+
inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8, const T9& arg9) {
296296
throw Rcpp::exception( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9).c_str() );
297297
}
298298

299299
template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9, typename T10>
300-
inline void stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8, const T9& arg9, const T10& arg10) {
300+
inline void NORET stop(const char* fmt, const T1& arg1, const T2& arg2, const T3& arg3, const T4& arg4, const T5& arg5, const T6& arg6, const T7& arg7, const T8& arg8, const T9& arg9, const T10& arg10) {
301301
throw Rcpp::exception( tfm::format(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10).c_str() );
302302
}
303303
}

0 commit comments

Comments
 (0)