Bug 41856 - g++.dg/lookup/extern-c-redecl[3,4] .C should be target specific
Summary: g++.dg/lookup/extern-c-redecl[3,4] .C should be target specific
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: testsuite (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Dodji Seketeli
URL:
Keywords:
: 41890 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-10-28 13:17 UTC by Jack Howarth
Modified: 2009-11-02 23:02 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-10-28 15:38:45


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jack Howarth 2009-10-28 13:17:29 UTC
Two of the new testcases introduced in r153552 fail on both powerpc-apple-darwin9 and x86_64-apple-darwin10...

FAIL: g++.dg/lookup/extern-c-redecl3.C scan-assembler call[\\t ]+fork
FAIL: g++.dg/lookup/extern-c-redecl4.C scan-assembler call[\\t ]+_Z4forkv
Comment 1 Jakub Jelinek 2009-10-28 14:00:29 UTC
I guess it is going to fail on many more targets.
One issue is that only some targets have call insn called that way, it can have many other names on other targets.  Even on ix86/x86_64 it could be tail called and be it jmp fork instead of call fork.  The second issue is that some targets put various prefixes before the symbol name, guess the most often used one is just an extra _ prefix.
So, probably the test should be limited to ix86/x86_64, ensure it is not built with optimizations and accept extra optional _ before symbol name.
Comment 2 Dodji Seketeli 2009-10-28 15:38:44 UTC
Yes, I'll limit the test to ix86/x86_64. Patch coming soon.
Comment 3 dodji@seketeli.org 2009-10-28 20:53:10 UTC
Subject: Re:  g++.dg/lookup/extern-c-redecl[3,4] .C
	scan-assembler fails on darwin

Does this patch qualify as obvious ?

/bin/bash: call : commande introuvable
diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C b/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
index 00ff4a9..3f2fee2 100644
--- a/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
+++ b/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
@@ -1,8 +1,9 @@
 // Contributed by Dodji Seketeli <dodji@redhat.com>
 // Origin: PR c++/41020
+// { dg-options "-O0" }
 // { dg-do compile }
-// { dg-final { scan-assembler-not "call\[\t \]+_Z4forkv" } }
-// { dg-final { scan-assembler "call\[\t \]+fork" } }
+// { dg-final { scan-assembler-not "call\[\t \]+_?_Z4forkv" { target i?86-*-* x86_64-*-* } } }
+// { dg-final { scan-assembler "call\[\t \]+_?fork" { target i?86-*-* x86_64-*-* } } }
 
 extern "C" int fork (void);
 
diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C b/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
index 9dfa54d..bbe625e 100644
--- a/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
+++ b/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
@@ -1,10 +1,9 @@
 // Contributed by Dodji Seketeli <dodji@redhat.com>
 // Origin: PR c++/41020
 
-// Avoid the "-ansi -pedantic" option
-// { dg-options "" }
+// { dg-options "-O0" }
 // { dg-do compile }
-// { dg-final { scan-assembler "call\[\t \]+_Z4forkv" } }
+// { dg-final { scan-assembler "call\[\t \]+_?_Z4forkv" { target i?86-*-* x86_64-*-* } } }
 
 class frok
 {

Comment 4 Dominique d'Humieres 2009-10-28 21:41:13 UTC
On i686-apple-darwin9, with the patch I get:

Running target unix
Using /sw/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /sw/share/dejagnu/config/unix.exp as generic interface file for target.
Using /opt/gcc/gcc-4.5-work/gcc/testsuite/config/default.exp as tool-and-target-specific interface file.
Running /opt/gcc/gcc-4.5-work/gcc/testsuite/g++.dg/dg.exp ...
FAIL: g++.dg/lookup/extern-c-redecl4.C scan-assembler call[\t ]+_?_Z4forkv

		=== g++ Summary for unix ===

# of expected passes		11
# of unexpected failures	1
Running target unix/-m64
Using /sw/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /sw/share/dejagnu/config/unix.exp as generic interface file for target.
Using /opt/gcc/gcc-4.5-work/gcc/testsuite/config/default.exp as tool-and-target-specific interface file.
Running /opt/gcc/gcc-4.5-work/gcc/testsuite/g++.dg/dg.exp ...

		=== g++ Summary for unix/-m64 ===

# of expected passes		12

		=== g++ Summary ===

# of expected passes		23
# of unexpected failures	1
/Volumes/MacBook/opt/gcc/i686-darwin/gcc/testsuite/g++/../../g++  version 4.5.0 20091028 (experimental) [trunk revision 153644p3d] (GCC) 

grepping the assembly file for ++.dg/lookup/extern-c-redecl4.C compiled with -m32, I see

	call	L__Z4forkv$stub
	call	LPC$1

The failure disappears with the following patch:

--- ../_gcc_clean/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C	2009-10-26 17:19:09.000000000 +0100
+++ gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C	2009-10-28 22:39:48.000000000 +0100
@@ -2,9 +2,9 @@
 // Origin: PR c++/41020
 
 // Avoid the "-ansi -pedantic" option
-// { dg-options "" }
+// { dg-options "-O0" }
 // { dg-do compile }
-// { dg-final { scan-assembler "call\[\t \]+_Z4forkv" } }
+// { dg-final { scan-assembler "call\[\t \]+L?_?_Z4forkv" { target i?86-*-* x86_64-*-* } } }
 
 class frok
 {
Comment 5 dodji@seketeli.org 2009-10-29 07:22:20 UTC
Subject: Re:  g++.dg/lookup/extern-c-redecl[3,4] .C
	scan-assembler fails on darwin

Thanks for testing.

How about this one ?

diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C b/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
index 00ff4a9..117c6d1 100644
--- a/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
+++ b/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
@@ -1,8 +1,9 @@
 // Contributed by Dodji Seketeli <dodji@redhat.com>
 // Origin: PR c++/41020
+// { dg-options "" }
 // { dg-do compile }
-// { dg-final { scan-assembler-not "call\[\t \]+_Z4forkv" } }
-// { dg-final { scan-assembler "call\[\t \]+fork" } }
+// { dg-final { scan-assembler-not "call\[\t \]+.*?_Z4forkv" { target i?86-*-* x86_64-*-* } } }
+// { dg-final { scan-assembler "call\[\t \]+_?fork" { target i?86-*-* x86_64-*-* } } }
 
 extern "C" int fork (void);
 
diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C b/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
index 9dfa54d..a4515fd 100644
--- a/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
+++ b/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
@@ -1,10 +1,9 @@
 // Contributed by Dodji Seketeli <dodji@redhat.com>
 // Origin: PR c++/41020
 
-// Avoid the "-ansi -pedantic" option
 // { dg-options "" }
 // { dg-do compile }
-// { dg-final { scan-assembler "call\[\t \]+_Z4forkv" } }
+// { dg-final { scan-assembler "call\[\t \]+.*?_Z4forkv" { target i?86-*-* x86_64-*-* } } }
 
 class frok
 {
Comment 6 Dominique d'Humieres 2009-10-29 14:36:04 UTC
Without test the part '.*?' in the rerexps seems odd. Why not '.*' only?  My practice of regexp taught me that '.*' is asking for trouble and, when possible, should be replaced by [^some pattern]*. Why not "call[^Z]*Z4forkv" (not regtested, but it works when grepping the assembly)?
Comment 7 dodji@seketeli.org 2009-10-29 17:09:22 UTC
Subject: Re:  g++.dg/lookup/extern-c-redecl[3,4] .C
	scan-assembler fails on darwin

> ------- Comment #6 from dominiq at lps dot ens dot fr  2009-10-29 14:36 -------
> Without test the part '.*?' in the rerexps seems odd. Why not '.*' only?
The '.*?' is the non greedy form of '.*'. If I put '.*' only, then '.*foo'
'.*' will match the foo coming after and that will not do what I want.

Comment 8 Andreas Schwab 2009-10-29 17:29:02 UTC
(In reply to comment #7)
> The '.*?' is the non greedy form of '.*'. If I put '.*' only, then '.*foo'
> '.*' will match the foo coming after and that will not do what I want.

The nongreedy form will not prevent that.  You should never use '.*' because '.' can match newline.
Comment 9 Dominique d'Humieres 2009-10-31 17:13:41 UTC
> The '.*?' is the non greedy form of '.*'.

I have learnt regexps at a time when this was not available on all regexp engines, so I always forget such constructs.

I think pr41890 is a duplicate of this one.
Comment 10 H.J. Lu 2009-10-31 17:31:54 UTC
*** Bug 41890 has been marked as a duplicate of this bug. ***
Comment 11 John David Anglin 2009-10-31 22:00:51 UTC
Also fail on hppa*-*-hpux*.
Comment 12 Dodji Seketeli 2009-11-02 20:20:31 UTC
Subject: Re:  g++.dg/lookup/extern-c-redecl[3,4] .C
	scan-assembler fails on darwin

Sorry for my late reply.
Could you please test this patch on darwin ?

Thanks.

diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C b/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
index 00ff4a9..56dcefa 100644
--- a/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
+++ b/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
@@ -1,8 +1,9 @@
 // Contributed by Dodji Seketeli <dodji@redhat.com>
 // Origin: PR c++/41020
+// { dg-options "" }
 // { dg-do compile }
-// { dg-final { scan-assembler-not "call\[\t \]+_Z4forkv" } }
-// { dg-final { scan-assembler "call\[\t \]+fork" } }
+// { dg-final { scan-assembler-not "call\[\t \]+\[^\$\]*?_Z4forkv" { target i?86-*-* x86_64-*-* } } }
+// { dg-final { scan-assembler "call\[\t \]+_?fork" { target i?86-*-* x86_64-*-* } } }
 
 extern "C" int fork (void);
 
diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C b/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
index 9dfa54d..c385ea7 100644
--- a/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
+++ b/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
@@ -1,10 +1,9 @@
 // Contributed by Dodji Seketeli <dodji@redhat.com>
 // Origin: PR c++/41020
 
-// Avoid the "-ansi -pedantic" option
 // { dg-options "" }
 // { dg-do compile }
-// { dg-final { scan-assembler "call\[\t \]+_Z4forkv" } }
+// { dg-final { scan-assembler "call\[\t \]+\[^\$\]*?_Z4forkv" { target i?86-*-* x86_64-*-* } } }
 
 class frok
 {
Comment 13 Dominique d'Humieres 2009-11-02 21:21:33 UTC
Running target unix
Using /sw/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /sw/share/dejagnu/config/unix.exp as generic interface file for target.
Using /opt/gcc/gcc-4.5-work/gcc/testsuite/config/default.exp as tool-and-target-specific interface file.
Running /opt/gcc/gcc-4.5-work/gcc/testsuite/g++.dg/dg.exp ...

		=== g++ Summary for unix ===

# of expected passes		12
Running target unix/-m64
Using /sw/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /sw/share/dejagnu/config/unix.exp as generic interface file for target.
Using /opt/gcc/gcc-4.5-work/gcc/testsuite/config/default.exp as tool-and-target-specific interface file.
Running /opt/gcc/gcc-4.5-work/gcc/testsuite/g++.dg/dg.exp ...

> Could you please test this patch on darwin ?

With the patch in comment#12 I get on i686-apple-darwin9:

make -k check-g++ RUNTESTFLAGS="dg.exp=lookup/extern-c-redecl* --target_board=unix'{,-m64}'"

...
Running target unix
Using /sw/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /sw/share/dejagnu/config/unix.exp as generic interface file for target.
Using /opt/gcc/gcc-4.5-work/gcc/testsuite/config/default.exp as tool-and-target-specific interface file.
Running /opt/gcc/gcc-4.5-work/gcc/testsuite/g++.dg/dg.exp ...

		=== g++ Summary for unix ===

# of expected passes		12
Running target unix/-m64
Using /sw/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /sw/share/dejagnu/config/unix.exp as generic interface file for target.
Using /opt/gcc/gcc-4.5-work/gcc/testsuite/config/default.exp as tool-and-target-specific interface file.
Running /opt/gcc/gcc-4.5-work/gcc/testsuite/g++.dg/dg.exp ...

		=== g++ Summary for unix/-m64 ===

# of expected passes		12

		=== g++ Summary ===

# of expected passes		24
/Volumes/MacBook/opt/gcc/i686-darwin/gcc/testsuite/g++/../../g++  version 4.5.0 20091102 (experimental) [trunk revision 153817p1] (GCC) 
Comment 14 Dodji Seketeli 2009-11-02 22:58:19 UTC
Subject: Bug 41856

Author: dodji
Date: Mon Nov  2 22:58:07 2009
New Revision: 153829

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153829
Log:
Fix PR c++/41856

	PR c++/41856
	* g++.dg/lookup/extern-c-redecl3.C: Make the test x86
	only.
	* g++.dg/lookup/extern-c-redecl4.C: Likewise.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
    trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C

Comment 15 Dodji Seketeli 2009-11-02 23:02:22 UTC
Fixed in 4.5.
Comment 16 Dodji Seketeli 2009-11-03 13:47:05 UTC
Subject: Bug 41856

Author: dodji
Date: Tue Nov  3 13:46:46 2009
New Revision: 153851

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153851
Log:
Fix PR c++/41856

	PR c++/41856
	* g++.dg/lookup/extern-c-redecl3.C: Make the test x86 only.
	* g++.dg/lookup/extern-c-redecl4.C: Likewise.

Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C