]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl2.c (build_anon_union_vars): Copy attributes from the base addr.
authorRichard Henderson <rth@redhat.com>
Mon, 12 Sep 2005 04:04:03 +0000 (21:04 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Mon, 12 Sep 2005 04:04:03 +0000 (21:04 -0700)
        * 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.

From-SVN: r104160

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/error8.C

index 012b6e20fcfade78d93da438387cd902a9719ed8..4ea174c8fe770b37378844d319e98a90fa414d82 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-11  Richard Henderson  <rth@redhat.com>
+
+       * decl2.c (build_anon_union_vars): Copy attributes from the base addr.
+       * pt.c (tsubst_decl): Substitute in DECL_VALUE_EXPR.
+
 2005-09-09  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * parser.c (cp_parser_translation_unit): Simplify.  The while-block
index 8ef6fa863fd06d7b98e6a712889245e318b8c5b5..c2a90fc5bc564c23462c3f450769805cbe2afbde 100644 (file)
@@ -1101,12 +1101,18 @@ build_anon_union_vars (tree type, tree object)
 
       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 f78da9338cc2e5007535df2d7e1089c60dde882d..85e8cb83b868f7c8cfbacd521fda3062cd6363ed 100644 (file)
@@ -6674,6 +6674,13 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
            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 2b374e84c2840bb9dc2db59832d94c2288ac8dce..a4b62de409943fecd1b86143efee35de50214964 100644 (file)
@@ -1,3 +1,7 @@
+2005-09-11  Richard Henderson  <rth@redhat.com>
+
+       * g++.dg/other/error8.C: Update expected diagnostic text.
+
 2005-09-11  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        PR libfortran/19872
index 1ccfe99befe55b6f0b08f9a42c3d00a1f2011950..9246c2afa564339354ad548c69eeecaed6fd73da 100644 (file)
@@ -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 }