]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Suppressed compiler warnings reported by gcc 4.4.x on the source code
authorBart Van Assche <bvanassche@acm.org>
Wed, 12 Aug 2009 12:55:56 +0000 (12:55 +0000)
committerBart Van Assche <bvanassche@acm.org>
Wed, 12 Aug 2009 12:55:56 +0000 (12:55 +0000)
of regression tests about intentionally uninitialized variables and
about intentionally freed non-heap memory.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10794

configure.in
memcheck/tests/Makefile.am
memcheck/tests/badfree.c
memcheck/tests/xml1.c

index 5c7c7256dbc8cc352c9c70bcfa079b804bb5a42e..f4ee9c33be93699fe373efd1c56969b6fd80f7cc 100644 (file)
@@ -1255,6 +1255,29 @@ AC_MSG_RESULT([no])
 CFLAGS=$safe_CFLAGS
 
 
+# does this compiler support -Wno-uninitialized ?
+
+AC_MSG_CHECKING([if gcc accepts -Wno-uninitialized])
+
+safe_CFLAGS=$CFLAGS
+CFLAGS="-Wno-uninitialized"
+
+AC_TRY_COMPILE(
+[ ],
+[
+  return 0;
+],
+[
+AC_SUBST([FLAG_W_NO_UNINITIALIZED], [-Wno-uninitialized])
+AC_MSG_RESULT([yes])
+],
+[
+AC_SUBST([FLAG_W_NO_UNINITIALIZED], [])
+AC_MSG_RESULT([no])
+])
+CFLAGS=$safe_CFLAGS
+
+
 # does this compiler support -Wextra or the older -W ?
 
 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
index 14200ad5a6504414db5f1bab69208cb254098f74..43a44a8518381c898dbf0fa0779434faf711f042 100644 (file)
@@ -251,8 +251,14 @@ endif
 deep_templates_SOURCES = deep_templates.cpp
 deep_templates_CXXFLAGS        = $(AM_CFLAGS) -O -gstabs
 
+error_counts_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
+
+inits_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
+
 long_namespace_xml_SOURCES = long_namespace_xml.cpp
 
+manuel1_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
+
 memcmptest_CFLAGS      = $(AM_CFLAGS) -fno-builtin-memcmp
 
 mismatches_SOURCES     = mismatches.cpp
@@ -260,6 +266,10 @@ mismatches_SOURCES = mismatches.cpp
 new_nothrow_SOURCES    = new_nothrow.cpp
 new_override_SOURCES   = new_override.cpp
 
+origin2_not_quite_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
+
+origin3_no_CFLAGS = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
+
 # This requires optimisation in order to get just one resulting error.
 origin4_many_CFLAGS    = $(AM_CFLAGS) -O
 
index 3a225677647084783b01a61612838550582f7e9b..f9393c7753b5444f59ed8255e38dacfa74a9f8f8 100644 (file)
@@ -2,7 +2,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-
+static void* return_arg(void* q);
 int main ( void )
 {
    void* p = (void*)0x87654321;
@@ -12,7 +12,18 @@ int main ( void )
    free(p);
 
    /* Free a pointer to a stack block */
-   free(q);
+   free(return_arg(q));
 
    return 0;
 }
+
+/*
+ * The only purpose of the function below is to make sure that gcc 4.4.x does
+ * not print the following warning during the compilation of this test program:
+ * warning: attempt to free a non-heap object
+ */
+static void* return_arg(void* q)
+{
+   return q;
+}
+
index abf2d3887eafc65da7de197a07dca56671ab5e6b..6cab2878d86f01c9b2ea7001dbf073f2d2a94be9 100644 (file)
@@ -2,7 +2,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
-
+static void* return_arg(void* p);
 int frame3 ( void )
 {
   int *a = malloc(10 * sizeof(int));
@@ -25,7 +25,7 @@ int frame3 ( void )
   free(a);
 
   // more invalid frees
-  free(&n);
+  free(return_arg(&n));
 
   // leak ..
   a = malloc(99 * sizeof(int));
@@ -48,3 +48,14 @@ int main ( void )
 {
   return frame1() - 1;
 }
+
+/*
+ * The only purpose of the function below is to make sure that gcc 4.4.x does
+ * not print the following warning during the compilation of this test program:
+ * warning: attempt to free a non-heap object
+ */
+static void* return_arg(void* p)
+{
+   return p;
+}
+