Implement diagnostic ignore macro for Clang

Newer versions of Clang now also complain about -Wscript-prototypes for included
headers.

Closes GH-12467
This commit is contained in:
Ilija Tovilo 2023-10-18 11:25:12 +02:00
parent 0de79a8f5a
commit 80b4c73030
No known key found for this signature in database
GPG key ID: A4F5D403F118200A
6 changed files with 30 additions and 16 deletions

View file

@ -70,6 +70,9 @@ PHP 8.3 INTERNALS UPGRADE NOTES
* _php_stream_dirent now has an extra d_type field that is used to store the * _php_stream_dirent now has an extra d_type field that is used to store the
directory entry type. This can be used to avoid additional stat calls for directory entry type. This can be used to avoid additional stat calls for
types when the type is already known. types when the type is already known.
* The misspelled ZEND_CGG_DIAGNOSTIC_IGNORED_(START|END) macros are deprecated.
Use ZEND_DIAGNOSTIC_IGNORED_(START|END) instead. These macros now also support
Clang.
======================== ========================
2. Build system changes 2. Build system changes

View file

@ -737,19 +737,30 @@ extern "C++" {
# define ZEND_INDIRECT_RETURN # define ZEND_INDIRECT_RETURN
#endif #endif
#if __GNUC__ && !defined(__clang__) #define __ZEND_DO_PRAGMA(x) _Pragma(#x)
# define __DO_PRAGMA(x) _Pragma(#x) #define _ZEND_DO_PRAGMA(x) __ZEND_DO_PRAGMA(x)
# define _DO_PRAGMA(x) __DO_PRAGMA(x) #if defined(__clang__)
# define ZEND_CGG_DIAGNOSTIC_IGNORED_START(warning) \ # define ZEND_DIAGNOSTIC_IGNORED_START(warning) \
_Pragma("clang diagnostic push") \
_ZEND_DO_PRAGMA(clang diagnostic ignored warning)
# define ZEND_DIAGNOSTIC_IGNORED_END \
_Pragma("clang diagnostic pop")
#elif defined(__GNUC__)
# define ZEND_DIAGNOSTIC_IGNORED_START(warning) \
_Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic push") \
_DO_PRAGMA(GCC diagnostic ignored warning) _ZEND_DO_PRAGMA(GCC diagnostic ignored warning)
# define ZEND_CGG_DIAGNOSTIC_IGNORED_END \ # define ZEND_DIAGNOSTIC_IGNORED_END \
_Pragma("GCC diagnostic pop") _Pragma("GCC diagnostic pop")
#else #else
# define ZEND_CGG_DIAGNOSTIC_IGNORED_START(warning) # define ZEND_DIAGNOSTIC_IGNORED_START(warning)
# define ZEND_CGG_DIAGNOSTIC_IGNORED_END # define ZEND_DIAGNOSTIC_IGNORED_END
#endif #endif
/** @deprecated */
#define ZEND_CGG_DIAGNOSTIC_IGNORED_START ZEND_DIAGNOSTIC_IGNORED_START
/** @deprecated */
#define ZEND_CGG_DIAGNOSTIC_IGNORED_END ZEND_DIAGNOSTIC_IGNORED_END
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */
# define ZEND_STATIC_ASSERT(c, m) _Static_assert((c), m) # define ZEND_STATIC_ASSERT(c, m) _Static_assert((c), m)
#else #else

View file

@ -47,9 +47,9 @@
# endif # endif
/* these are used for quota support */ /* these are used for quota support */
ZEND_CGG_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes") ZEND_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes")
# include "c-client.h" /* includes mail.h and rfc822.h */ # include "c-client.h" /* includes mail.h and rfc822.h */
ZEND_CGG_DIAGNOSTIC_IGNORED_END ZEND_DIAGNOSTIC_IGNORED_END
# include "imap4r1.h" /* location of c-client quota functions */ # include "imap4r1.h" /* location of c-client quota functions */
#else #else
# include "mail.h" # include "mail.h"

View file

@ -53,9 +53,9 @@
/* }}} */ /* }}} */
#include "ext/standard/php_string.h" #include "ext/standard/php_string.h"
ZEND_CGG_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes") ZEND_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes")
#include <oci.h> #include <oci.h>
ZEND_CGG_DIAGNOSTIC_IGNORED_END ZEND_DIAGNOSTIC_IGNORED_END
#if !defined(OCI_MAJOR_VERSION) || OCI_MAJOR_VERSION < 11 || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION < 2)) #if !defined(OCI_MAJOR_VERSION) || OCI_MAJOR_VERSION < 11 || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION < 2))
#error This version of PHP OCI8 requires Oracle Client libraries from 11.2 or later. #error This version of PHP OCI8 requires Oracle Client libraries from 11.2 or later.

View file

@ -19,9 +19,9 @@
#include "zend_portability.h" #include "zend_portability.h"
ZEND_CGG_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes") ZEND_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes")
#include <oci.h> #include <oci.h>
ZEND_CGG_DIAGNOSTIC_IGNORED_END ZEND_DIAGNOSTIC_IGNORED_END
typedef struct { typedef struct {
const char *file; const char *file;

View file

@ -2387,11 +2387,11 @@ iterator_done:
if (soap_version == SOAP_1_1) { if (soap_version == SOAP_1_1) {
smart_str_0(&array_type); smart_str_0(&array_type);
#if defined(__GNUC__) && __GNUC__ >= 11 #if defined(__GNUC__) && __GNUC__ >= 11
ZEND_CGG_DIAGNOSTIC_IGNORED_START("-Wstringop-overread") ZEND_DIAGNOSTIC_IGNORED_START("-Wstringop-overread")
#endif #endif
bool is_xsd_any_type = strcmp(ZSTR_VAL(array_type.s),"xsd:anyType") == 0; bool is_xsd_any_type = strcmp(ZSTR_VAL(array_type.s),"xsd:anyType") == 0;
#if defined(__GNUC__) && __GNUC__ >= 11 #if defined(__GNUC__) && __GNUC__ >= 11
ZEND_CGG_DIAGNOSTIC_IGNORED_END ZEND_DIAGNOSTIC_IGNORED_END
#endif #endif
if (is_xsd_any_type) { if (is_xsd_any_type) {
smart_str_free(&array_type); smart_str_free(&array_type);