From 98c209e2fcee1b50470884aa9a0d65ba072b7d02 Mon Sep 17 00:00:00 2001 From: jason Date: Sun, 14 Feb 2010 15:17:30 +0000 Subject: [PATCH] PR c++/41997 * semantics.c (finish_compound_literal): Use cp_apply_type_quals_to_decl when creating a static variable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156760 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 1 + gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/initlist-opt.C | 19 +++++++++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/initlist-opt.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7e37b69545b..0b96f4c8fbf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-02-14 Jason Merrill + + PR c++/41997 + * semantics.c (finish_compound_literal): Use + cp_apply_type_quals_to_decl when creating a static variable. + 2010-02-12 Jason Merrill PR c++/43024 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 985e2c0f464..90a76d9391c 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2257,6 +2257,7 @@ finish_compound_literal (tree type, tree compound_literal) tree decl = create_temporary_var (type); DECL_INITIAL (decl) = compound_literal; TREE_STATIC (decl) = 1; + cp_apply_type_quals_to_decl (cp_type_quals (type), decl); decl = pushdecl_top_level (decl); DECL_NAME (decl) = make_anon_name (); SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 157d79cb4c8..891e33d5e5a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-02-14 Jason Merrill + + PR c++/41997 + * g++.dg/cpp0x/initlist-opt.C: New. + 2010-02-13 Paul Thomas PR fortran/41113 diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-opt.C b/gcc/testsuite/g++.dg/cpp0x/initlist-opt.C new file mode 100644 index 00000000000..f515ed89d98 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist-opt.C @@ -0,0 +1,19 @@ +// PR c++/41997 +// { dg-options "-std=c++0x -O2 -fdump-tree-optimized" } +// { dg-final { scan-tree-dump-not "_0" "optimized" } } +// { dg-final { cleanup-tree-dump "optimized" } } + +#include + +int max_val(std::initializer_list il) +{ + int i = *(il.begin()); + int j = *(il.begin() + 1); + return (i > j ? i : j); +} + +int main(void) +{ + return max_val({1,2}); +} + -- 2.11.4.GIT