fix some c++ testsuite regressions

Richard Henderson rth@redhat.com
Mon Sep 12 03:32:00 GMT 2005


... that I caused.  All anon union related.  For some reason, I only
saw the failures on powerpc, not on i686.


r~


	* decl2.c (build_anon_union_vars): Copy attributes from the base addr.
	* pt.c (tsubst_decl): Substitute in DECL_VALUE_EXPR.

	* g++.dg/other/error8.C: Update expected diagnostic text.

Index: gcc/cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.801
diff -u -p -r1.801 decl2.c
--- gcc/cp/decl2.c	9 Sep 2005 21:00:46 -0000	1.801
+++ gcc/cp/decl2.c	12 Sep 2005 03:27:28 -0000
@@ -1101,12 +1101,18 @@ build_anon_union_vars (tree type, tree o
 
       if (DECL_NAME (field))
 	{
+	  tree base;
+
 	  decl = build_decl (VAR_DECL, DECL_NAME (field), TREE_TYPE (field));
-	  TREE_PUBLIC (decl) = TREE_PUBLIC (object);
-	  TREE_STATIC (decl) = TREE_PUBLIC (object);
-	  DECL_EXTERNAL (decl) = DECL_EXTERNAL (object);
+
+	  base = get_base_address (object);
+	  TREE_PUBLIC (decl) = TREE_PUBLIC (base);
+	  TREE_STATIC (decl) = TREE_STATIC (base);
+	  DECL_EXTERNAL (decl) = DECL_EXTERNAL (base);
+
 	  SET_DECL_VALUE_EXPR (decl, ref);
 	  DECL_HAS_VALUE_EXPR_P (decl) = 1;
+
 	  decl = pushdecl (decl);
 	}
       else if (ANON_AGGR_TYPE_P (TREE_TYPE (field)))
Index: gcc/cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.1030
diff -u -p -r1.1030 pt.c
--- gcc/cp/pt.c	9 Sep 2005 18:56:14 -0000	1.1030
+++ gcc/cp/pt.c	12 Sep 2005 03:27:30 -0000
@@ -6674,6 +6674,13 @@ tsubst_decl (tree t, tree args, tsubst_f
 	    DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (r)
 	      = DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (t);
 	    type = check_var_type (DECL_NAME (r), type);
+
+	    if (DECL_HAS_VALUE_EXPR_P (t))
+	      {
+		tree ve = DECL_VALUE_EXPR (t);
+		ve = tsubst_expr (ve, args, complain, in_decl);
+	        SET_DECL_VALUE_EXPR (r, ve);
+	      }
 	  }
 	else if (DECL_SELF_REFERENCE_P (t))
 	  SET_DECL_SELF_REFERENCE_P (r);
Index: gcc/testsuite/g++.dg/other/error8.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/other/error8.C,v
retrieving revision 1.3
diff -u -p -r1.3 error8.C
--- gcc/testsuite/g++.dg/other/error8.C	4 Oct 2004 06:04:42 -0000	1.3
+++ gcc/testsuite/g++.dg/other/error8.C	12 Sep 2005 03:27:30 -0000
@@ -5,8 +5,8 @@
 
 void foo(void)
 {
-  union { int alpha; int beta; }; // { dg-error "previous declaration of 'int alpha'" }
-  double alpha;  // { dg-error "redeclared" }
+  union { int alpha; int beta; }; // { dg-error "previous declaration" }
+  double alpha;  // { dg-error "conflicting declaration" }
 }
 
 // This checks both the templated version, and the position of the diagnostic
@@ -20,7 +20,3 @@ void tfoo(void)
   }; // { dg-bogus "" "misplaced position of the declaration" { xfail *-*-* } }
   double alpha; // { dg-error "" "" }
 }
-
-// The duplicated error messages are xfailed for now (tracked in the PR)
-// { dg-bogus "" "duplicate error messages" { target *-*-* } 8 }
-// { dg-bogus "" "duplicate error messages" { target *-*-* } 9 }



More information about the Gcc-patches mailing list