diff options
author | Jason Merrill <jason@redhat.com> | 2011-12-08 17:28:38 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-12-08 17:28:38 -0500 |
commit | 0ee1c847f75174bb87a54edb32f7f7cf27681300 (patch) | |
tree | 72c3586becdc548da2d22a9612b89d1ffdc537bf | |
parent | 4eefc795c1af34738cbbe5839fc20415f7b20f39 (diff) | |
download | gcc-0ee1c847f75174bb87a54edb32f7f7cf27681300.zip gcc-0ee1c847f75174bb87a54edb32f7f7cf27681300.tar.gz gcc-0ee1c847f75174bb87a54edb32f7f7cf27681300.tar.bz2 |
re PR c++/51318 (segfault on Eigen3)
PR c++/51318
* typeck.c (build_x_conditional_expr): Restrict glvalue games to C++11.
From-SVN: r182142
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/cond8.C | 10 |
4 files changed, 20 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 70a93bd..14e65c0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-12-08 Jason Merrill <jason@redhat.com> + PR c++/51318 + * typeck.c (build_x_conditional_expr): Restrict glvalue games to C++11. + PR c++/51459 * pt.c (tsubst_expr) [DECL_EXPR]: Handle capture proxies properly. * semantics.c (insert_capture_proxy): No longer static. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 9a5365c..4973d7d 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -5517,8 +5517,10 @@ build_x_conditional_expr (tree ifexp, tree op1, tree op2, { tree min = build_min_non_dep (COND_EXPR, expr, orig_ifexp, orig_op1, orig_op2); - /* Remember that the result is an lvalue or xvalue. */ - if (lvalue_or_rvalue_with_address_p (expr) + /* In C++11, remember that the result is an lvalue or xvalue. + In C++98, lvalue_kind can just assume lvalue in a template. */ + if (cxx_dialect >= cxx0x + && lvalue_or_rvalue_with_address_p (expr) && !lvalue_or_rvalue_with_address_p (min)) TREE_TYPE (min) = cp_build_reference_type (TREE_TYPE (min), !real_lvalue_p (expr)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5c97305..9d4f286 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-12-08 Jason Merrill <jason@redhat.com> + PR c++/51318 + * g++.dg/template/cond8.C: New. + PR c++/51459 * g++.dg/cpp0x/lambda/lambda-template4.C: New. diff --git a/gcc/testsuite/g++.dg/template/cond8.C b/gcc/testsuite/g++.dg/template/cond8.C new file mode 100644 index 0000000..a3bad7e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/cond8.C @@ -0,0 +1,10 @@ +// PR c++/51318 + +enum { e0, e1 }; + +template<bool B, int = B ? e0 : e1> struct A {}; + +template<typename T> struct B +{ + A<T::X> a; +}; |