diff options
| author | Samuel Antao <sfantao@us.ibm.com> | 2016-07-22 16:05:35 +0000 |
|---|---|---|
| committer | Samuel Antao <sfantao@us.ibm.com> | 2016-07-22 16:05:35 +0000 |
| commit | 71fef77dcbef3884e98e2caf50cf69f071383e55 (patch) | |
| tree | 09d2339778402aafcdc28f39c156b6463ee244ae /openmp/runtime/src/thirdparty/ittnotify | |
| parent | b383d628dffb30b4ac63c346ca4a21a980bdfdd0 (diff) | |
| download | bcm5719-llvm-71fef77dcbef3884e98e2caf50cf69f071383e55.tar.gz bcm5719-llvm-71fef77dcbef3884e98e2caf50cf69f071383e55.zip | |
Replace enum types in variadic functions by build-in types.
Summary:
When compiling the runtime library with clang we get warnings like:
```
error: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Werror,-Wvarargs]
va_start( args, id );
^
note: parameter of type 'kmp_i18n_id_t' (aka 'kmp_i18n_id') is declared here
kmp_i18n_id_t id,
```
My understanding is that the va_start macro only gets the promoted type so it won't know what was the exact type of the argument, which can potentially not work for some targets given that the implementation of the the calling convention could not be done properly.
This patch fixes that by using a built-in type in the function signature.
Reviewers: tlwilmar, jlpeyton, AndreyChurbanov
Subscribers: arpith-jacob, carlo.bertolli, caomhin, openmp-commits
Differential Revision: https://reviews.llvm.org/D22427
llvm-svn: 276428
Diffstat (limited to 'openmp/runtime/src/thirdparty/ittnotify')
| -rw-r--r-- | openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.c b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.c index 5f365730eac..89a716dc0ab 100644 --- a/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.c +++ b/openmp/runtime/src/thirdparty/ittnotify/ittnotify_static.c @@ -285,10 +285,16 @@ ITT_EXTERN_C void _N_(error_handler)(__itt_error_code, va_list args); #pragma warning(disable: 4055) /* warning C4055: 'type cast' : from data pointer 'void *' to function pointer 'XXX' */ #endif /* ITT_PLATFORM==ITT_PLATFORM_WIN */ -static void __itt_report_error(__itt_error_code code, ...) +static void __itt_report_error(unsigned code_arg, ...) { va_list args; - va_start(args, code); + va_start(args, code_arg); + + // We use unsigned for the code argument and explicitly cast it here to the + // right enumerator because variadic functions are not compatible with + // default promotions. + __itt_error_code code = (__itt_error_code)code_arg; + if (_N_(_ittapi_global).error_handler != NULL) { __itt_error_handler_t* handler = (__itt_error_handler_t*)(size_t)_N_(_ittapi_global).error_handler; |

