From 6500d3078d883942ba312f77be03c5df0a80476b Mon Sep 17 00:00:00 2001 From: paolo Date: Thu, 8 Sep 2011 14:58:21 +0000 Subject: [PATCH] /cp 2011-09-08 Paolo Carlini PR c++/50324 * typeck2.c (digest_init_r): Call complete_type_or_maybe_complain instead of complete_type_or_else. /testsuite 2011-09-08 Paolo Carlini PR c++/50324 * g++.dg/cpp0x/sfinae28.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178694 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/typeck2.c | 7 ++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/sfinae28.C | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/sfinae28.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8ee3087..9fbbbee 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-09-08 Paolo Carlini + + PR c++/50324 + * typeck2.c (digest_init_r): Call complete_type_or_maybe_complain + instead of complete_type_or_else. + 2011-09-08 Dodji Seketeli PR c++/33255 - Support -Wunused-local-typedefs warning diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 901e4ee..1c0bb38 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1,7 +1,7 @@ /* Report error messages, build initializers, and perform some front-end optimizations for C++ compiler. Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Hacked by Michael Tiemann (tiemann@cygnus.com) @@ -812,8 +812,9 @@ digest_init_r (tree type, tree init, bool nested, int flags, /* We must strip the outermost array type when completing the type, because the its bounds might be incomplete at the moment. */ - if (!complete_type_or_else (TREE_CODE (type) == ARRAY_TYPE - ? TREE_TYPE (type) : type, NULL_TREE)) + if (!complete_type_or_maybe_complain (TREE_CODE (type) == ARRAY_TYPE + ? TREE_TYPE (type) : type, NULL_TREE, + complain)) return error_mark_node; /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e6c4db0..fcf62c7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-09-08 Paolo Carlini + + PR c++/50324 + * g++.dg/cpp0x/sfinae28.C: New. + 2011-09-08 Dodji Seketeli PR c++/33255 - Support -Wunused-local-typedefs warning diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae28.C b/gcc/testsuite/g++.dg/cpp0x/sfinae28.C new file mode 100644 index 0000000..da64f41 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae28.C @@ -0,0 +1,16 @@ +// PR c++/50324 +// { dg-options -std=c++0x } + +struct complete { }; +struct incomplete; + +template auto f(T *) -> decltype(T{}) *; +template char f(T); + +int main() +{ + complete *p = 0; + static_assert(sizeof(f(p)) == sizeof(void*), ""); + incomplete *q = 0; + static_assert(sizeof(f(q)) == 1u, ""); +} -- 2.7.4