From patchwork Fri Oct 15 21:43:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: C++ PATCH for c++/45983 (-flto trying to emit template parm) Date: Fri, 15 Oct 2010 11:43:44 -0000 From: Jason Merrill X-Patchwork-Id: 68004 Message-Id: <4CB8CB10.2010505@redhat.com> To: gcc-patches List The bug in this testcase was that cp_build_qualified_type's array handling was treating an array of a typedef as identical to an array of a non-typedef, which allowed a typedef from a template to be reused outside. Tested x86_64-pc-linux-gnu, applied to trunk. commit 2a6ccacef80355a5b8867c85f409a9d02e065f9e Author: Jason Merrill Date: Fri Oct 15 17:12:27 2010 -0400 PR c++/45983 * tree.c (cp_build_qualified_type_real): Don't reuse a variant with a different typedef variant of the element type. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 93d13a1..b8f76b0 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -810,7 +810,7 @@ cp_build_qualified_type_real (tree type, /* See if we already have an identically qualified type. Tests should be equivalent to those in check_qualified_type. */ for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t)) - if (cp_type_quals (t) == type_quals + if (TREE_TYPE (t) == element_type && TYPE_NAME (t) == TYPE_NAME (type) && TYPE_CONTEXT (t) == TYPE_CONTEXT (type) && attribute_list_equal (TYPE_ATTRIBUTES (t), diff --git a/gcc/testsuite/g++.dg/lto/pr45983_0.C b/gcc/testsuite/g++.dg/lto/pr45983_0.C new file mode 100644 index 0000000..a2c9ba6 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr45983_0.C @@ -0,0 +1,20 @@ +// PR c++/45983 + +template +class T1 { + int m[N]; + typedef float scalar_type_t; + typedef scalar_type_t scalar_array_t[1]; + const scalar_array_t &decay(void) const; +}; +class T2 { +public: + float vals[1]; + float get_value(void) const { return vals[0]; } +}; +T2 channel_params; +float output_audio(void) { + return channel_params.get_value(); +} + +int main(){}