Skip to content

Commit f9e2e85

Browse files
authored
[Clang] Use const pointer to eliminate warning with libxml 2.12.0 (#76719)
Currently, if `CLANG_HAVE_LIBXML` is defined, and the version of libxml2 is above 2.12.0, there will be two warnings when building clang. warning: initializing 'xmlErrorPtr' (aka 'struct _xmlError *') with an expression of type 'const xmlError *' (aka 'const struct _xmlError *') discards qualifiers Since this commit https://gitlab.gnome.org/GNOME/libxml2/-/commit/45470611b047db78106dcb2fdbd4164163c15ab7, libxml2 makes cmlGetLastError return a const error. This patch follows libxml2. Making the result a const pointer should be compatible with versions before 2.12.0. Tested on ArchLinux with libxml2 2.12.3 installed.
1 parent 62bf771 commit f9e2e85

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/tools/c-index-test/c-index-test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ static void ValidateCommentXML(const char *Str, const char *CommentSchemaFile) {
707707
Doc = xmlParseDoc((const xmlChar *) Str);
708708

709709
if (!Doc) {
710-
xmlErrorPtr Error = xmlGetLastError();
710+
const xmlError *Error = xmlGetLastError();
711711
printf(" CommentXMLInvalid [not well-formed XML: %s]", Error->message);
712712
return;
713713
}
@@ -717,7 +717,7 @@ static void ValidateCommentXML(const char *Str, const char *CommentSchemaFile) {
717717
if (!status)
718718
printf(" CommentXMLValid");
719719
else if (status > 0) {
720-
xmlErrorPtr Error = xmlGetLastError();
720+
const xmlError *Error = xmlGetLastError();
721721
printf(" CommentXMLInvalid [not valid XML: %s]", Error->message);
722722
} else
723723
printf(" libXMLError");

0 commit comments

Comments
 (0)