I’m updating Hedley to support the new nvcc/nvc++/pgcc/pgc++, and I’m noticing that a lot of diagnostic numbers are one value higher than they were before. For example:
__attribute__((__nonnull__(1)))
static const char* non_null(const char* msg) {
return msg;
}
int main (void) {
non_null(nullptr);
return 0;
}
nemequ@peltast:~/t$ /opt/nvidia/hpc_sdk/Linux_x86_64/20.7/compilers/bin/nvc++ --display_error_number -Minform=inform -Werror -o wtf wtf.cpp
"wtf.cpp", line 7: error #1623: null argument provided for parameter marked
with attribute "nonnull"
non_null(nullptr);
^
1 error detected in the compilation of "wtf.cpp".
nemequ@peltast:~/t$ /opt/pgi/19.10/linux86-64/19.10/bin/pgc++ --display_error_number -Minform=inform -Werror -o wtf wtf.cpp
"wtf.cpp", line 7: error #1622: null argument provided for parameter marked
with attribute "nonnull"
non_null(nullptr);
^
1 error detected in the compilation of "wtf.cpp".
It’s not just this warning, it seems like it might be all of them. The warning for a missing sentinel (for a function with the sentinel
attribute) changed from 1546 to 1547, and using a symbol marked as deprecated changed from 1215 and 1444 (depending on whether the symbol is a variable or a function) to 1216 and 1445.
Obviously this isn’t a catastrophe, but it does mean I have to go through all my code and update the warning numbers, which results in a rather silly patch:
diff --git a/hedley.h b/hedley.h
index d343075..d436897 100644
--- a/hedley.h
+++ b/hedley.h
@@ -851,6 +851,8 @@
# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
#elif HEDLEY_INTEL_VERSION_CHECK(13,0,0)
# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)")
+#elif HEDLEY_PGI_VERSION_CHECK(20,7,0)
+# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1216,1445")
#elif HEDLEY_PGI_VERSION_CHECK(17,10,0)
# define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444")
#elif HEDLEY_GCC_VERSION_CHECK(4,3,0)
@@ -920,6 +922,8 @@
# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)")
#elif HEDLEY_MSVC_VERSION_CHECK(19,0,0)
# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030))
+#elif HEDLEY_PGI_VERSION_CHECK(20,7,0)
+# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1098")
#elif HEDLEY_PGI_VERSION_CHECK(17,10,0)
# define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097")
#elif HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)
@@ -1263,7 +1267,7 @@ HEDLEY_DIAGNOSTIC_POP
# define HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr))
#endif
#if \
- HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \
+ (HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(HEDLEY_PGI_VERSION)) || \
HEDLEY_GCC_VERSION_CHECK(9,0,0)
# define HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability))
# define HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability))
diff --git a/test/non-null.c b/test/non-null.c
index 0ac0ed2..48488e1 100644
--- a/test/non-null.c
+++ b/test/non-null.c
@@ -9,7 +9,9 @@
#include <stdlib.h>
#endif
-#if defined(HEDLEY_PGI_VERSION)
+#if HEDLEY_PGI_VERSION_CHECK(20,7,0)
+# pragma diag_remark 1623
+#elif defined(HEDLEY_PGI_VERSION)
# pragma diag_remark 1622
#elif HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)
# pragma error_messages(off,nonnullarg)
diff --git a/test/sentinel.c b/test/sentinel.c
index 0e2c492..18c3257 100644
--- a/test/sentinel.c
+++ b/test/sentinel.c
@@ -4,6 +4,8 @@
# pragma clang diagnostic warning "-Wsentinel"
#elif defined(HEDLEY_INTEL_VERSION)
# pragma warning(disable:1881)
+#elif HEDLEY_PGI_VERSION_CHECK(20,7,0)
+# pragma diag_remark 1547
#elif defined(HEDLEY_PGI_VERSION)
# pragma diag_remark 1546
#elif defined(HEDLEY_GNUC_VERSION)
diff --git a/test/warn-unused-result.c b/test/warn-unused-result.c
index 1d9437c..41dc795 100644
--- a/test/warn-unused-result.c
+++ b/test/warn-unused-result.c
@@ -12,6 +12,8 @@
defined(HEDLEY_TI_CL7X_VERSION) || \
defined(HEDLEY_TI_CLPRU_VERSION)
# pragma diag_remark 1490
+#elif HEDLEY_PGI_VERSION_CHECK(20,7,0)
+# pragma diag_remark 1651
#elif defined(HEDLEY_PGI_VERSION)
# pragma diag_remark 1650
#elif defined(HEDLEY_GNUC_VERSION)
diff --git a/test/warn.c b/test/warn.c
index 67a677e..d2d8604 100644
--- a/test/warn.c
+++ b/test/warn.c
@@ -2,6 +2,8 @@
#if defined(HEDLEY_INTEL_VERSION)
# pragma warning(disable:1028)
+#elif HEDLEY_PGI_VERSION_CHECK(20,7,0)
+# pragma diag_remark 1106
#elif defined(HEDLEY_PGI_VERSION)
# pragma diag_remark 1105
#endif
I have a feeling this is unintentional since it’s a pretty disruptive change with (AFAICT) no benefit. However, if it is unintentional and you’ll revert to the old diagnostic numbers in the next release I’ll need to update my code to only use the larger numbers for 20.7 instead of 20.7+.
Can you let me know whether the numbers will revert next release or if these are going to be the values for the foreseeable future?