]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/7363 (bogus __alignof__ implementation)
authorMark Mitchell <mark@codesourcery.com>
Tue, 29 Oct 2002 21:12:36 +0000 (21:12 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 29 Oct 2002 21:12:36 +0000 (21:12 +0000)
PR c++/7363
* semantics.c (finish_alignof): Call complete_type before calling
c_alignof.
* decl2.c (build_expr_from_tree): Use
finish_sizeof/finish_alignof.

* g++.dg/template/alignof1.C: New test.

From-SVN: r58634

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/alignof1.C [new file with mode: 0644]

index c9c1741b8603a217dcc91ef661fb4a168643ac14..eaba75521948e1ca3a1b03a4a5e10a98e5e10e32 100644 (file)
@@ -1,3 +1,10 @@
+2002-10-29  Mark Mitchell  <mark@codesourcery.com>
+
+       * semantics.c (finish_alignof): Call complete_type before calling
+       c_alignof.
+       * decl2.c (build_expr_from_tree): Use
+       finish_sizeof/finish_alignof.
+
 2002-10-10  Jim Wilson  <wilson@redhat.com>
 
        * decl.c (duplicate_decls): Don't call decl_attributes.
index 43349631b4de6c6431903f1372b6f12b04a87980..871fefc5130285eb0556f1cec30edac59e28b336 100644 (file)
@@ -3795,10 +3795,8 @@ build_expr_from_tree (t)
     case ALIGNOF_EXPR:
       {
        tree r = build_expr_from_tree (TREE_OPERAND (t, 0));
-       if (!TYPE_P (r))
-         return TREE_CODE (t) == SIZEOF_EXPR ? expr_sizeof (r) : c_alignof_expr (r);
-       else
-         return TREE_CODE (t) == SIZEOF_EXPR ? c_sizeof (r) : c_alignof (r);
+       return (TREE_CODE (t) == SIZEOF_EXPR
+               ? finish_sizeof (r) : finish_alignof (r));
       }
 
     case MODOP_EXPR:
index 43d3074dca38166df065fd2e740eb4ab8b42a6d5..a4842036d8d317cac91df6d35ceb46a7df977ce2 100644 (file)
@@ -2117,7 +2117,7 @@ finish_alignof (t)
   if (processing_template_decl)
     return build_min_nt (ALIGNOF_EXPR, t);
 
-  return TYPE_P (t) ? c_alignof (t) : c_alignof_expr (t);
+  return TYPE_P (t) ? c_alignof (complete_type (t)) : c_alignof_expr (t);
 }
 
 /* Generate RTL for the statement T, and its substatements, and any
index 385e25c847f3493b02d73a41bb5d0829257687f5..592de43a95303b30089f6ed499c0fe4e1634986a 100644 (file)
@@ -1,3 +1,7 @@
+2002-10-29  Mark Mitchell  <mark@codesourcery.com>
+
+       * g++.dg/template/alignof1.C: New test.
+
 2002-10-28  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.dg/20021014-1.c: Bypass errors on solaris2 and irix6.
diff --git a/gcc/testsuite/g++.dg/template/alignof1.C b/gcc/testsuite/g++.dg/template/alignof1.C
new file mode 100644 (file)
index 0000000..50a3218
--- /dev/null
@@ -0,0 +1,13 @@
+template<typename T>
+int my_alignof()
+{
+    return __alignof__(T);
+}
+
+template<typename>
+struct X { };
+
+int main()
+{
+  return my_alignof<X<void> >();
+}