Index: gcc/testsuite/ChangeLog.pph

2011-08-29   Lawrence Crowl  <crowl@google.com>

	* lib/dg-pph.exp: Move -fno-dwarf2-cfi-asm to end of command line.
	Add recognition of "pph asm xwant" when we desire assembly differences
	between pph and non-pph.
	* g++.dg/pph/x0keyno1.h: Correct test to not have a key method.
	* g++.dg/pph/x0keyno2.h: Likewise.
	* g++.dg/pph/x1keyno.cc: Likewise.
	* g++.dg/pph/x4keyno.cc: Likewise.
	* g++.dg/pph/x4keyex.cc: New.  Add test to capture the broken behavior
	in the original key4no.cc.
	* g++.dg/pph/x7rtti.cc: Eliminate an unresolved test by turning off
	dg-run until the compilation problems are fixed.
	* g++.dg/pph/x0resolve1.h: New test for overload behavior.
	* g++.dg/pph/x0resolve2.h: Likewise.
	* g++.dg/pph/x1resolve1.cc: Likewise.
	* g++.dg/pph/x1resolve2.cc: Likewise.
	* g++.dg/pph/x4resolve1.cc: Likewise.
	* g++.dg/pph/x4resolve2.cc: Likewise.


Index: gcc/testsuite/lib/dg-pph.exp
===================================================================
--- gcc/testsuite/lib/dg-pph.exp	(revision 178269)
+++ gcc/testsuite/lib/dg-pph.exp	(working copy)
@@ -54,7 +54,7 @@ proc dg-pph-neg { subdir test options ma
     verbose -log "\nTesting $nshort, $options"
 
     set dg-do-what-default compile
-    dg-test -keep-output $test "-fno-dwarf2-cfi-asm $options $mapflag -I." ""
+    dg-test -keep-output $test "$options $mapflag -I. -fno-dwarf2-cfi-asm" ""
 
     if { [file_on_host exists "$bname.s"] } {
 	file_on_host delete "$bname.s"
@@ -76,7 +76,7 @@ proc dg-pph-pos { subdir test options ma
 
     # Compile the file the first time for a base case.
     set dg-do-what-default compile
-    dg-test -keep-output $test "-fno-dwarf2-cfi-asm $options -I." ""
+    dg-test -keep-output $test "$options -I. -fno-dwarf2-cfi-asm" ""
 
     # Determine whether this is an assembly comparison test
     set is_exec [llength [grep $test "dg-do run"]]
@@ -102,7 +102,7 @@ proc dg-pph-pos { subdir test options ma
     verbose -log ""
 
     # Compile a second time using the pph files.
-    dg-test -keep-output $test "-fno-dwarf2-cfi-asm $options $mapflag -I." ""
+    dg-test -keep-output $test "$options $mapflag -I. -fno-dwarf2-cfi-asm" ""
 
     if { !$is_asm } {
 	# No assembly means we cannot compare them,
@@ -127,16 +127,24 @@ proc dg-pph-pos { subdir test options ma
 
     verbose -log ""
 
-    # Compare the two assembly files.  They should be identical.
+    # Compare the two assembly files.
+    # In most tests, they should be identical.
+    # Tests involving overload injection and such will have different assembly.
     set adiff [catch {exec diff "$bname.s-pph" "$bname.s+pph"} diff_result]
     # The sources mark when they expect the comparison to differ.
+    # When marked with xdiff, the difference is a problem.
+    # When marked with xwant, the difference is what we want.
     set xdiff_entry [grep $test "pph asm xdiff( )*\[0-9\]*"]
+    set xwant_entry [grep $test "pph asm xwant( )*\[0-9\]*"]
     set xdiff [llength $xdiff_entry]
+    set xwant [llength $xwant_entry]
     if { $adiff == 0 } {
 	if { $xdiff } {
-	    xpass "$nshort $options (assembly comparison)"
+	    xpass "$nshort $options (assembly equality)"
+	} elseif { $xwant } {
+	    fail "$nshort $options (assembly difference)"
 	} else {
-	    pass "$nshort $options (assembly comparison)"
+	    pass "$nshort $options (assembly equality)"
 	}
 	file_on_host delete "$bname.s-pph"
 	file_on_host delete "$bname.s+pph"
@@ -150,13 +158,21 @@ proc dg-pph-pos { subdir test options ma
 	if { $xdiff } {
 	    set expectedSum [lindex [split $xdiff_entry " \}"] 3]
 	    if { $expectedSum == $actualSum } {
-	        xfail "$nshort $options (assembly comparison)"
+	        xfail "$nshort $options (assembly equality)"
 	    } else {
 		set sumMessage "sums $expectedSum=>$actualSum"
-	        fail "$nshort $options (assembly comparison, $sumMessage)"
+	        fail "$nshort $options (assembly equality, $sumMessage)"
+	    }
+	} elseif { $xwant } {
+	    set expectedSum [lindex [split $xwant_entry " \}"] 3]
+	    if { $expectedSum == $actualSum } {
+	        pass "$nshort $options (assembly difference)"
+	    } else {
+		set sumMessage "sums $expectedSum=>$actualSum"
+	        fail "$nshort $options (assembly equality, $sumMessage)"
 	    }
 	} else {
-	    fail "$nshort $options (assembly comparison, sum=$actualSum)"
+	    fail "$nshort $options (assembly equality, sum=$actualSum)"
 	}
     } else {
 	fail "$nshort $options comparison failure"
Index: gcc/testsuite/g++.dg/pph/x4resolve1.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x4resolve1.cc	(revision 0)
+++ gcc/testsuite/g++.dg/pph/x4resolve1.cc	(revision 0)
@@ -0,0 +1,9 @@
+// pph asm xwant 53261
+
+#include "x0resolve1.h"
+#include "x0resolve2.h"
+
+int caller()
+{
+    return overloader1() + overloader2();
+}
Index: gcc/testsuite/g++.dg/pph/x4keyex.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x4keyex.cc	(revision 0)
+++ gcc/testsuite/g++.dg/pph/x4keyex.cc	(revision 0)
@@ -0,0 +1,25 @@
+// pph asm xdiff 32642
+//
+// This test case fails to compare because LFB/LFE labels are different.
+//
+// 1- Both x0keyno1.h and x0keyno2.h declare exactly the same, as
+//    they both textually include a0keyed.h.
+// 2- When we read x0keyno1.pph, we instantiate all the decls and cgraph
+//    nodes for struct keyed.
+// 3- When we read x0keyno2.pph, we re-instantiate the same decls and
+//    cgraph nodes, which are used instead of the ones in x0keyno1.pph.
+// 4- Since the new decls and nodes have been created later, the functions
+//    have different function numbers (function::funcdef_no field), which
+//    is used to emit the LFB/LFE labels.
+//
+// The future merging process will fix this by choosing the decls and nodes
+// created first by x0keyno1.pph.
+
+#include "x0keyed1.h"
+#include "x0keyed2.h"
+
+int main()
+{
+    keyed variable;
+    return variable.mix( 3 );
+}
Index: gcc/testsuite/g++.dg/pph/x0resolve2.h
===================================================================
--- gcc/testsuite/g++.dg/pph/x0resolve2.h	(revision 0)
+++ gcc/testsuite/g++.dg/pph/x0resolve2.h	(revision 0)
@@ -0,0 +1,12 @@
+#ifndef X0RESOLVE2_H
+#define X0RESOLVE2_H
+
+int intfunc(long x);
+int fltfunc(double x);
+
+inline int overloader2()
+{
+    return intfunc(3) + fltfunc(2.0f);
+}
+
+#endif
Index: gcc/testsuite/g++.dg/pph/x0keyno1.h
===================================================================
--- gcc/testsuite/g++.dg/pph/x0keyno1.h	(revision 178269)
+++ gcc/testsuite/g++.dg/pph/x0keyno1.h	(working copy)
@@ -1,4 +1,4 @@
-#ifndef X0KEYED1_H
-#define X0KEYED1_H
-#include "a0keyed.h"
+#ifndef X0KEYNO1_H
+#define X0KEYNO1_H
+#include "a0keyno.h"
 #endif
Index: gcc/testsuite/g++.dg/pph/x1keyno.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x1keyno.cc	(revision 178269)
+++ gcc/testsuite/g++.dg/pph/x1keyno.cc	(working copy)
@@ -2,6 +2,6 @@
 
 int main()
 {
-    keyed variable;
+    keyno variable;
     return variable.mix( 3 );
 }
Index: gcc/testsuite/g++.dg/pph/x4keyno.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x4keyno.cc	(revision 178269)
+++ gcc/testsuite/g++.dg/pph/x4keyno.cc	(working copy)
@@ -1,25 +1,11 @@
-// pph asm xdiff 32642
-//
-// This test case fails to compare because LFB/LFE labels are different.
-//
-// 1- Both x0keyno1.h and x0keyno2.h declare exactly the same, as
-//    they both textually include a0keyed.h.
-// 2- When we read x0keyno1.pph, we instantiate all the decls and cgraph
-//    nodes for struct keyed.
-// 3- When we read x0keyno2.pph, we re-instantiate the same decls and
-//    cgraph nodes, which are used instead of the ones in x0keyno1.pph.
-// 4- Since the new decls and nodes have been created later, the functions
-//    have different function numbers (function::funcdef_no field), which
-//    is used to emit the LFB/LFE labels.
-//
-// The future merging process will fix this by choosing the decls and nodes
-// created first by x0keyno1.pph.
+// { dg-xfail-if "BOGUS" { "*-*-*" } { "-fpph-map=pph.map" } }
+// { dg-bogus "x4keyno.cc:11:1: error: redefinition of 'const char _ZTS5keyno" "" { xfail *-*-* } 0 }
 
 #include "x0keyno1.h"
 #include "x0keyno2.h"
 
 int main()
 {
-    keyed variable;
+    keyno variable;
     return variable.mix( 3 );
 }
Index: gcc/testsuite/g++.dg/pph/x1resolve2.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x1resolve2.cc	(revision 0)
+++ gcc/testsuite/g++.dg/pph/x1resolve2.cc	(revision 0)
@@ -0,0 +1,6 @@
+#include "x0resolve2.h"
+
+int caller()
+{
+    return overloader2();
+}
Index: gcc/testsuite/g++.dg/pph/x4resolve2.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x4resolve2.cc	(revision 0)
+++ gcc/testsuite/g++.dg/pph/x4resolve2.cc	(revision 0)
@@ -0,0 +1,9 @@
+// pph asm xwant 12527
+
+#include "x0resolve2.h"
+#include "x0resolve1.h"
+
+int caller()
+{
+    return overloader1() + overloader2();
+}
Index: gcc/testsuite/g++.dg/pph/x0keyno2.h
===================================================================
--- gcc/testsuite/g++.dg/pph/x0keyno2.h	(revision 178269)
+++ gcc/testsuite/g++.dg/pph/x0keyno2.h	(working copy)
@@ -1,4 +1,4 @@
-#ifndef X0KEYED2_H
-#define X0KEYED2_H
-#include "a0keyed.h"
+#ifndef X0KEYNO2_H
+#define X0KEYNO2_H
+#include "a0keyno.h"
 #endif
Index: gcc/testsuite/g++.dg/pph/x7rtti.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x7rtti.cc	(revision 178269)
+++ gcc/testsuite/g++.dg/pph/x7rtti.cc	(working copy)
@@ -1,4 +1,4 @@
-// { dg-do run }
+// FIXME pph: This should be a { dg=do run } (with '=' replaced by '-')
 // { dg-xfail-if "BOGUS" { "*-*-*" } { "-fpph-map=pph.map" } }
 // { dg-bogus "x7rtti.cc:19:0: warning: .__STDC_IEC_559_COMPLEX__. redefined .enabled by default." "" { xfail *-*-* } 0 }
 // { dg-bogus "x7rtti.cc:19:0: warning: .__STDC_ISO_10646__. redefined .enabled by default." "" { xfail *-*-* } 0 }
Index: gcc/testsuite/g++.dg/pph/x1resolve1.cc
===================================================================
--- gcc/testsuite/g++.dg/pph/x1resolve1.cc	(revision 0)
+++ gcc/testsuite/g++.dg/pph/x1resolve1.cc	(revision 0)
@@ -0,0 +1,6 @@
+#include "x0resolve1.h"
+
+int caller()
+{
+    return overloader1();
+}
Index: gcc/testsuite/g++.dg/pph/x0resolve1.h
===================================================================
--- gcc/testsuite/g++.dg/pph/x0resolve1.h	(revision 0)
+++ gcc/testsuite/g++.dg/pph/x0resolve1.h	(revision 0)
@@ -0,0 +1,12 @@
+#ifndef X0RESOLVE1_H
+#define X0RESOLVE1_H
+
+int intfunc(int x);
+int fltfunc(float x);
+
+inline int overloader1()
+{
+    return intfunc(3l) + fltfunc(2.0);
+}
+
+#endif
