diff options
Diffstat (limited to 'gcc/cp/semantics.cc')
-rw-r--r-- | gcc/cp/semantics.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index 640b2d7..07c2b33 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -3272,12 +3272,17 @@ finish_compound_literal (tree type, tree compound_literal, /* Represent other compound literals with TARGET_EXPR so we produce a prvalue, and can elide copies. */ - if (!VECTOR_TYPE_P (type)) + if (TREE_CODE (compound_literal) == CONSTRUCTOR + || TREE_CODE (compound_literal) == VEC_INIT_EXPR) { /* The CONSTRUCTOR is now an initializer, not a compound literal. */ - TREE_HAS_CONSTRUCTOR (compound_literal) = false; + if (TREE_CODE (compound_literal) == CONSTRUCTOR) + TREE_HAS_CONSTRUCTOR (compound_literal) = false; compound_literal = get_target_expr_sfinae (compound_literal, complain); } + else + /* For e.g. int{42} just make sure it's a prvalue. */ + compound_literal = rvalue (compound_literal); return compound_literal; } |