diff options
Diffstat (limited to 'gcc/cp/typeck.c')
-rw-r--r-- | gcc/cp/typeck.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index e67d1b12c25..0a322e3356b 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1887,6 +1887,15 @@ decay_conversion (tree exp, tsubst_flags_t complain) return error_mark_node; } + /* Don't let an array compound literal decay to a pointer. It can + still be used to initialize an array or bind to a reference. */ + if (TREE_CODE (exp) == TARGET_EXPR) + { + if (complain & tf_error) + error_at (loc, "taking address of temporary array"); + return error_mark_node; + } + ptrtype = build_pointer_type (TREE_TYPE (type)); if (TREE_CODE (exp) == VAR_DECL) |