Skip to content

Commit 80b4c73

Browse files
committed
Implement diagnostic ignore macro for Clang
Newer versions of Clang now also complain about -Wscript-prototypes for included headers. Closes GH-12467
1 parent 0de79a8 commit 80b4c73

File tree

6 files changed

+30
-16
lines changed

6 files changed

+30
-16
lines changed

UPGRADING.INTERNALS

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ PHP 8.3 INTERNALS UPGRADE NOTES
7070
* _php_stream_dirent now has an extra d_type field that is used to store the
7171
directory entry type. This can be used to avoid additional stat calls for
7272
types when the type is already known.
73+
* The misspelled ZEND_CGG_DIAGNOSTIC_IGNORED_(START|END) macros are deprecated.
74+
Use ZEND_DIAGNOSTIC_IGNORED_(START|END) instead. These macros now also support
75+
Clang.
7376

7477
========================
7578
2. Build system changes

Zend/zend_portability.h

+19-8
Original file line numberDiff line numberDiff line change
@@ -737,19 +737,30 @@ extern "C++" {
737737
# define ZEND_INDIRECT_RETURN
738738
#endif
739739

740-
#if __GNUC__ && !defined(__clang__)
741-
# define __DO_PRAGMA(x) _Pragma(#x)
742-
# define _DO_PRAGMA(x) __DO_PRAGMA(x)
743-
# define ZEND_CGG_DIAGNOSTIC_IGNORED_START(warning) \
740+
#define __ZEND_DO_PRAGMA(x) _Pragma(#x)
741+
#define _ZEND_DO_PRAGMA(x) __ZEND_DO_PRAGMA(x)
742+
#if defined(__clang__)
743+
# define ZEND_DIAGNOSTIC_IGNORED_START(warning) \
744+
_Pragma("clang diagnostic push") \
745+
_ZEND_DO_PRAGMA(clang diagnostic ignored warning)
746+
# define ZEND_DIAGNOSTIC_IGNORED_END \
747+
_Pragma("clang diagnostic pop")
748+
#elif defined(__GNUC__)
749+
# define ZEND_DIAGNOSTIC_IGNORED_START(warning) \
744750
_Pragma("GCC diagnostic push") \
745-
_DO_PRAGMA(GCC diagnostic ignored warning)
746-
# define ZEND_CGG_DIAGNOSTIC_IGNORED_END \
751+
_ZEND_DO_PRAGMA(GCC diagnostic ignored warning)
752+
# define ZEND_DIAGNOSTIC_IGNORED_END \
747753
_Pragma("GCC diagnostic pop")
748754
#else
749-
# define ZEND_CGG_DIAGNOSTIC_IGNORED_START(warning)
750-
# define ZEND_CGG_DIAGNOSTIC_IGNORED_END
755+
# define ZEND_DIAGNOSTIC_IGNORED_START(warning)
756+
# define ZEND_DIAGNOSTIC_IGNORED_END
751757
#endif
752758

759+
/** @deprecated */
760+
#define ZEND_CGG_DIAGNOSTIC_IGNORED_START ZEND_DIAGNOSTIC_IGNORED_START
761+
/** @deprecated */
762+
#define ZEND_CGG_DIAGNOSTIC_IGNORED_END ZEND_DIAGNOSTIC_IGNORED_END
763+
753764
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */
754765
# define ZEND_STATIC_ASSERT(c, m) _Static_assert((c), m)
755766
#else

ext/imap/php_imap.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
# endif
4848

4949
/* these are used for quota support */
50-
ZEND_CGG_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes")
50+
ZEND_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes")
5151
# include "c-client.h" /* includes mail.h and rfc822.h */
52-
ZEND_CGG_DIAGNOSTIC_IGNORED_END
52+
ZEND_DIAGNOSTIC_IGNORED_END
5353
# include "imap4r1.h" /* location of c-client quota functions */
5454
#else
5555
# include "mail.h"

ext/oci8/php_oci8_int.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
/* }}} */
5454

5555
#include "ext/standard/php_string.h"
56-
ZEND_CGG_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes")
56+
ZEND_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes")
5757
#include <oci.h>
58-
ZEND_CGG_DIAGNOSTIC_IGNORED_END
58+
ZEND_DIAGNOSTIC_IGNORED_END
5959

6060
#if !defined(OCI_MAJOR_VERSION) || OCI_MAJOR_VERSION < 11 || ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION < 2))
6161
#error This version of PHP OCI8 requires Oracle Client libraries from 11.2 or later.

ext/pdo_oci/php_pdo_oci_int.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
#include "zend_portability.h"
2121

22-
ZEND_CGG_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes")
22+
ZEND_DIAGNOSTIC_IGNORED_START("-Wstrict-prototypes")
2323
#include <oci.h>
24-
ZEND_CGG_DIAGNOSTIC_IGNORED_END
24+
ZEND_DIAGNOSTIC_IGNORED_END
2525

2626
typedef struct {
2727
const char *file;

ext/soap/php_encoding.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2387,11 +2387,11 @@ static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style, xmlNod
23872387
if (soap_version == SOAP_1_1) {
23882388
smart_str_0(&array_type);
23892389
#if defined(__GNUC__) && __GNUC__ >= 11
2390-
ZEND_CGG_DIAGNOSTIC_IGNORED_START("-Wstringop-overread")
2390+
ZEND_DIAGNOSTIC_IGNORED_START("-Wstringop-overread")
23912391
#endif
23922392
bool is_xsd_any_type = strcmp(ZSTR_VAL(array_type.s),"xsd:anyType") == 0;
23932393
#if defined(__GNUC__) && __GNUC__ >= 11
2394-
ZEND_CGG_DIAGNOSTIC_IGNORED_END
2394+
ZEND_DIAGNOSTIC_IGNORED_END
23952395
#endif
23962396
if (is_xsd_any_type) {
23972397
smart_str_free(&array_type);

0 commit comments

Comments
 (0)