Skip to content

Commit 9fee4c9

Browse files
committed
use parentheses instead to prevent masking of individual calls
1 parent bb3001b commit 9fee4c9

File tree

5 files changed

+5
-15
lines changed

5 files changed

+5
-15
lines changed

ChangeLog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* inst/include/Rcpp/macros/mask.h: Mask Rf_error with Rcpp::stop with
44
a warning at compilation time, unless RCPP_NO_MASK_RF_ERROR is defined
55
* inst/include/RcppCommon.h: Include the previous file in the last place
6-
* src/attributes.cpp: Use RCPP_NO_MASK to protect call to Rf_error
6+
* src/attributes.cpp: Use parentheses to protect call to Rf_error
77
* inst/tinytest/cpp/stack.cpp: Idem
88
* inst/tinytest/testRcppInterfaceExporter/src/RcppExports.cpp: Idem
99

inst/include/Rcpp/macros/mask.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
#ifndef Rcpp_macros_mask_h
2121
#define Rcpp_macros_mask_h
2222

23-
#define RCPP_NO_MASK_EMPTY()
24-
#define RCPP_NO_MASK(id) id RCPP_NO_MASK_EMPTY()
25-
2623
#ifndef RCPP_NO_MASK_RF_ERROR
2724
#define Rf_error(...) \
2825
_Pragma("GCC warning \"Use of Rf_error() replaced with Rcpp::stop(). Calls \

inst/tinytest/cpp/stack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ SEXP testSendInterrupt() {
5656
SEXP maybeThrow(void* data) {
5757
bool* fail = (bool*) data;
5858
if (*fail)
59-
RCPP_NO_MASK(Rf_error)("throw!");
59+
(Rf_error)("throw!"); // prevent masking
6060
else
6161
return NumericVector::create(42);
6262
}

inst/tinytest/testRcppInterfaceExporter/src/RcppExports.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ RcppExport SEXP _testRcppInterfaceExporter_test_cpp_interface(SEXP xSEXP, SEXP f
4343
if (rcpp_isError_gen) {
4444
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
4545
UNPROTECT(1);
46-
#ifdef RCPP_NO_MASK
47-
RCPP_NO_MASK(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
48-
#else
49-
Rf_error("%s", CHAR(rcpp_msgSEXP_gen));
50-
#endif
46+
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
5147
}
5248
UNPROTECT(1);
5349
return rcpp_result_gen;

src/attributes.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,11 +2953,8 @@ namespace attributes {
29532953
<< " if (rcpp_isError_gen) {" << std::endl
29542954
<< " SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);" << std::endl
29552955
<< " UNPROTECT(1);" << std::endl
2956-
<< " #ifdef RCPP_NO_MASK" << std::endl
2957-
<< " RCPP_NO_MASK(Rf_error)(\"%s\", CHAR(rcpp_msgSEXP_gen));" << std::endl
2958-
<< " #else" << std::endl
2959-
<< " Rf_error(\"%s\", CHAR(rcpp_msgSEXP_gen));" << std::endl
2960-
<< " #endif" << std::endl
2956+
// Parentheses to prevent masking
2957+
<< " (Rf_error)(\"%s\", CHAR(rcpp_msgSEXP_gen));" << std::endl
29612958
<< " }" << std::endl
29622959
<< " UNPROTECT(1);" << std::endl
29632960
<< " return rcpp_result_gen;" << std::endl

0 commit comments

Comments
 (0)