From: jakub Date: Sun, 9 Dec 2007 21:26:29 +0000 (+0000) Subject: PR c++/34178 X-Git-Tag: upstream/4.9.2~44699 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af3f756da550426ce8cd5789e7279a947d82a4e2;p=platform%2Fupstream%2Flinaro-gcc.git PR c++/34178 PR c++/34340 * repo.c (repo_emit_p): Return 2 for DECL_INTEGRAL_CONSTANT_VAR_P in class scope rather than DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P. Return 2 also if DECL_EXPLICIT_INSTANTIATION. * decl2.c (import_export_decl): Don't make VAR_DECLs import_p when flag_use_repository and repo_emit_p returned 2. * g++.dg/template/repo6.C: New test. * g++.dg/template/repo7.C: New test. * g++.dg/template/repo8.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130727 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f7e8904..dccb575 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2007-12-09 Jakub Jelinek + + PR c++/34178 + PR c++/34340 + * repo.c (repo_emit_p): Return 2 for DECL_INTEGRAL_CONSTANT_VAR_P + in class scope rather than DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P. + Return 2 also if DECL_EXPLICIT_INSTANTIATION. + * decl2.c (import_export_decl): Don't make VAR_DECLs import_p when + flag_use_repository and repo_emit_p returned 2. + 2007-12-06 Jakub Jelinek PR c++/34336 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index bf3d598..37a21f7 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -2230,7 +2230,8 @@ import_export_decl (tree decl) { /* DECL is an implicit instantiation of a function or static data member. */ - if (flag_implicit_templates + if ((flag_implicit_templates + && !flag_use_repository) || (flag_implicit_inline_templates && TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl))) diff --git a/gcc/cp/repo.c b/gcc/cp/repo.c index 624d6d7..1fe96a2 100644 --- a/gcc/cp/repo.c +++ b/gcc/cp/repo.c @@ -304,16 +304,19 @@ repo_emit_p (tree decl) && (!TYPE_LANG_SPECIFIC (type) || !CLASSTYPE_TEMPLATE_INSTANTIATION (type))) return 2; - /* Static data members initialized by constant expressions must + /* Const static data members initialized by constant expressions must be processed where needed so that their definitions are available. */ - if (DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) + if (DECL_INTEGRAL_CONSTANT_VAR_P (decl) && DECL_CLASS_SCOPE_P (decl)) return 2; } else if (!DECL_TEMPLATE_INSTANTIATION (decl)) return 2; + if (DECL_EXPLICIT_INSTANTIATION (decl)) + return 2; + /* For constructors and destructors, the repository contains information about the clones -- not the original function -- because only the clones are emitted in the object file. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 958ede0..cc4338e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2007-12-09 Jakub Jelinek + + PR c++/34178 + PR c++/34340 + * g++.dg/template/repo6.C: New test. + * g++.dg/template/repo7.C: New test. + * g++.dg/template/repo8.C: New test. + 2007-12-09 H.J. Lu Tobias Burnus diff --git a/gcc/testsuite/g++.dg/template/repo6.C b/gcc/testsuite/g++.dg/template/repo6.C new file mode 100644 index 0000000..b15bab5 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/repo6.C @@ -0,0 +1,25 @@ +// PR c++/34178 +// { dg-options "-frepo" } +// { dg-final { cleanup-repo-files } } +// { dg-require-host-local "" } + +template +class A +{ +private: + static const int x; + static int y; + +public: + int getX () { return x + y; } +}; + +template const int A::x = 0; +template int A::y = 0; + +int +main () +{ + A a; + return a.getX(); +} diff --git a/gcc/testsuite/g++.dg/template/repo7.C b/gcc/testsuite/g++.dg/template/repo7.C new file mode 100644 index 0000000..7443315 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/repo7.C @@ -0,0 +1,24 @@ +// PR c++/34340 +// { dg-options "-frepo" } +// { dg-final { cleanup-repo-files } } +// { dg-require-host-local "" } + +struct A +{ + int a; +}; + +template struct D +{ + static const A b; +}; + +template const A D::b = { 2 }; +template class D; + +const A *x = &D::b; + +int +main () +{ +} diff --git a/gcc/testsuite/g++.dg/template/repo8.C b/gcc/testsuite/g++.dg/template/repo8.C new file mode 100644 index 0000000..840dc08 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/repo8.C @@ -0,0 +1,23 @@ +// PR c++/34340 +// { dg-options "-frepo" } +// { dg-final { cleanup-repo-files } } +// { dg-require-host-local "" } + +struct A +{ + int a; +}; + +template struct D +{ + static const A b; +}; + +template const A D::b = { 2 }; + +const A *x = &D::b; + +int +main () +{ +}