OSDN Git Service

2005-06-14 Frank Ch. Eigler <fche@redhat.com>
authorfche <fche@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Jun 2005 19:12:24 +0000 (19:12 +0000)
committerfche <fche@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Jun 2005 19:12:24 +0000 (19:12 +0000)
PR mudflap/21023
* tree-mudflap.c (mudflap_finish_file): Exclude non-public
rather than static objects (!) from libmudflap registration.

* testsuite/libmudflap.c/externs.exp, externs-{1,2}.c: New test files.
* testsuite/libmudflap.c/cfrags.exp: Bypass new sources.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100950 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-mudflap.c
libmudflap/ChangeLog
libmudflap/testsuite/libmudflap.c/cfrags.exp
libmudflap/testsuite/libmudflap.c/externs-1.c [new file with mode: 0644]
libmudflap/testsuite/libmudflap.c/externs-2.c [new file with mode: 0644]
libmudflap/testsuite/libmudflap.c/externs.exp [new file with mode: 0644]

index 0de0972..023b85d 100644 (file)
@@ -1,3 +1,9 @@
+2005-06-14  Frank Ch. Eigler  <fche@redhat.com>
+
+       PR mudflap/21023
+       * tree-mudflap.c (mudflap_finish_file): Exclude non-public
+       rather than static objects (!) from libmudflap registration.
+
 2005-06-14  Richard Sandiford  <richard@codesourcery.com>
 
        * opt-functions.awk (global_state_p, needs_state_p, static_var): New.
index 401e6b1..1ed0159 100644 (file)
@@ -1257,7 +1257,7 @@ mudflap_finish_file (void)
              Perform registration for non-static objects regardless of
              TREE_USED or TREE_ADDRESSABLE, because they may be used
              from other compilation units.  */
-          if (TREE_STATIC (obj) && ! TREE_ADDRESSABLE (obj))
+          if (! TREE_PUBLIC (obj) && ! TREE_ADDRESSABLE (obj))
             continue;
 
           if (! COMPLETE_TYPE_P (TREE_TYPE (obj)))
index 3cc2238..4e0525c 100644 (file)
@@ -1,5 +1,11 @@
 2005-06-14  Frank Ch. Eigler  <fche@redhat.com>
 
+       PR mudflap/21023
+       * testsuite/libmudflap.c/externs.exp, externs-{1,2}.c: New test files.
+       * testsuite/libmudflap.c/cfrags.exp: Bypass new sources.
+
+2005-06-14  Frank Ch. Eigler  <fche@redhat.com>
+
        PR libmudflap/21094
        * testsuite/libmudflap.c++/*.exp: Assert build tree g++.
 
index c29975c..577a4cc 100644 (file)
@@ -5,7 +5,11 @@ dg-init
 
 global srcdir
 foreach flags [list {} {-static} {-O2} {-O3}] {
-    foreach srcfile [lsort [glob -nocomplain ${srcdir}/libmudflap.c/*.c]] {
+    foreach srcfile [lsort [glob -nocomplain \
+                            ${srcdir}/libmudflap.c/*frag.c \
+                            ${srcdir}/libmudflap.c/heap*.c \
+                            ${srcdir}/libmudflap.c/hook*.c \
+                            ${srcdir}/libmudflap.c/pass*.c]] {
        set bsrc [file tail $srcfile]
        setenv MUDFLAP_OPTIONS "-viol-segv"
        dg-runtest $srcfile $flags "-fmudflap -lmudflap"
diff --git a/libmudflap/testsuite/libmudflap.c/externs-1.c b/libmudflap/testsuite/libmudflap.c/externs-1.c
new file mode 100644 (file)
index 0000000..552801d
--- /dev/null
@@ -0,0 +1,14 @@
+typedef struct { char *name; } dummy;
+extern dummy d[];
+
+int
+main (void)
+{
+  dummy *pd = d;
+
+  while (pd->name)
+    {
+      printf ("%s\n", pd->name);
+      pd++;
+    }
+}
diff --git a/libmudflap/testsuite/libmudflap.c/externs-2.c b/libmudflap/testsuite/libmudflap.c/externs-2.c
new file mode 100644 (file)
index 0000000..cecf625
--- /dev/null
@@ -0,0 +1,2 @@
+typedef struct { char *name; } dummy;
+dummy d[] = { {"a"}, {0} };
diff --git a/libmudflap/testsuite/libmudflap.c/externs.exp b/libmudflap/testsuite/libmudflap.c/externs.exp
new file mode 100644 (file)
index 0000000..e97e0b6
--- /dev/null
@@ -0,0 +1,40 @@
+libmudflap-init c
+dg-init
+
+global srcdir subdir
+
+foreach flags [list {} {-static} {-O2} {-O3}] {
+    set l1 [libmudflap_target_compile "$srcdir/$subdir/externs-1.c" "externs-1.o" object {additional_flags=-fmudflap}]
+    set test "externs-1 compilation ${flags}"
+    if [string match "*mudflap cannot track unknown size extern *d*" $l1] { pass $test } { fail $test }
+
+    set l2 [libmudflap_target_compile "$srcdir/$subdir/externs-2.c" "externs-2.o" object {additional_flags=-fmudflap}]
+    set test "externs-2 compilation ${flags}"
+    if [string match "" $l2]  { pass $test } { fail $test }
+
+    set l3 [libmudflap_target_compile "externs-1.o externs-2.o" "externs-12.exe" executable {additional_flags=-fmudflap additional_flags=-lmudflap}]
+    set test "externs-12 linkage ${flags}"
+    if [string match "" $l3]  { pass $test } { fail $test }
+
+    set l4 [libmudflap_target_compile "externs-2.o externs-1.o" "externs-21.exe" executable {additional_flags=-fmudflap additional_flags=-lmudflap}]
+    set test "externs-21 linkage ${flags}"
+    if [string match "" $l3]  { pass $test } { fail $test }
+
+    setenv MUDFLAP_OPTIONS "-viol-segv"
+
+    remote_spawn host "./externs-12.exe"
+    set l5 [remote_wait host 10]
+    set test "externs-12 execution ${flags}"
+    if {[lindex $l5 0] == 0}  { pass $test } { fail $test }
+
+    remote_spawn host "./externs-21.exe"
+    set l6 [remote_wait host 10]
+    set test "externs-21 execution ${flags}"
+    if {[lindex $l6 0] == 0}  { pass $test } { fail $test }
+
+    foreach f [glob -nocomplain "externs-*"] {
+       remote_file build delete $f
+    }
+}
+
+dg-finish