C++ PATCH: PR 28016
Mark Mitchell
mark@codesourcery.com
Sat Jun 17 04:57:00 GMT 2006
This patch fixes PR c++/28016. This is more fallout from the static
data member changes required to conform to the standard's requirements
that certain static data members not be value-dependent. In this
case, we were treating an uninstantiated static data member too much
like a real variable, and the back end was in fact emitting it. Eek.
Tested on x86_64-unknown-linux-gnu, applied on the mainline. I will
apply this to 4.1 once testing is complete.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
2006-06-16 Mark Mitchell <mark@codesourcery.com>
PR c++/28016
* decl.c (cp_finsh_decl): Do not emit uninstantiated static data
members.
2006-06-16 Mark Mitchell <mark@codesourcery.com>
PR c++/28016
* g++.dg/template/static26.C: New test.
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c (revision 114727)
+++ gcc/cp/decl.c (working copy)
@@ -5207,16 +5207,17 @@ cp_finish_decl (tree decl, tree init, bo
if (at_function_scope_p ())
add_decl_expr (decl);
- if (TREE_CODE (decl) == VAR_DECL)
- layout_var_decl (decl);
-
- /* Output the assembler code and/or RTL code for variables and functions,
- unless the type is an undefined structure or union.
- If not, it will get done when the type is completed. */
- if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
+ /* Let the middle end know about variables and functions -- but not
+ static data members in uninstantiated class templates. */
+ if (!saved_processing_template_decl
+ && (TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == FUNCTION_DECL))
{
if (TREE_CODE (decl) == VAR_DECL)
- maybe_commonize_var (decl);
+ {
+ layout_var_decl (decl);
+ maybe_commonize_var (decl);
+ }
make_rtl_for_nonlocal_decl (decl, init, asmspec);
Index: gcc/testsuite/g++.dg/template/static26.C
===================================================================
--- gcc/testsuite/g++.dg/template/static26.C (revision 0)
+++ gcc/testsuite/g++.dg/template/static26.C (revision 0)
@@ -0,0 +1,10 @@
+// PR c++/28016
+// { dg-final { scan-assembler-not "computed" } }
+
+template<class T1, class T2>
+struct scalar_divides_assign {
+ static const bool computed ;
+};
+
+template<class T1, class T2>
+const bool scalar_divides_assign<T1,T2>::computed = true;
More information about the Gcc-patches
mailing list