diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-29 09:30:50 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-29 09:30:50 +0000 |
commit | 8c7be932d4c52e939f3cbc5d234c28e9c52f9371 (patch) | |
tree | cee46ce3c49ae7d35611696938d3ec097d9852cb /gcc/cp/decl2.c | |
parent | 2a4ecd19dcccde445ee059728ccef3520ed772e4 (diff) | |
download | gcc-8c7be932d4c52e939f3cbc5d234c28e9c52f9371.tar.gz |
2012-03-29 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 185951 using svnmerge
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@185952 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r-- | gcc/cp/decl2.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 7eccf672546..b048ac7b3cd 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -151,6 +151,9 @@ change_return_type (tree new_ret, tree fntype) tree raises = TYPE_RAISES_EXCEPTIONS (fntype); tree attrs = TYPE_ATTRIBUTES (fntype); + if (new_ret == error_mark_node) + return fntype; + if (same_type_p (new_ret, TREE_TYPE (fntype))) return fntype; @@ -4281,7 +4284,11 @@ mark_used (tree decl) if ((TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL) || DECL_LANG_SPECIFIC (decl) == NULL || DECL_THUNK_P (decl)) - return true; + { + if (!processing_template_decl && type_uses_auto (TREE_TYPE (decl))) + error ("use of %qD before deduction of %<auto%>", decl); + return true; + } /* We only want to do this processing once. We don't need to keep trying to instantiate inline templates, because unit-at-a-time will make sure @@ -4303,10 +4310,13 @@ mark_used (tree decl) /* Normally, we can wait until instantiation-time to synthesize DECL. However, if DECL is a static data member initialized with a constant or a constexpr function, we need it right now because a reference to - such a data member or a call to such function is not value-dependent. */ + such a data member or a call to such function is not value-dependent. + For a function that uses auto in the return type, we need to instantiate + it to find out its type. */ if ((decl_maybe_constant_var_p (decl) || (TREE_CODE (decl) == FUNCTION_DECL - && DECL_DECLARED_CONSTEXPR_P (decl))) + && (DECL_DECLARED_CONSTEXPR_P (decl) + || type_uses_auto (TREE_TYPE (TREE_TYPE (decl)))))) && DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl) && !uses_template_parms (DECL_TI_ARGS (decl))) @@ -4321,6 +4331,9 @@ mark_used (tree decl) --function_depth; } + if (type_uses_auto (TREE_TYPE (decl))) + error ("use of %qD before deduction of %<auto%>", decl); + /* If we don't need a value, then we don't need to synthesize DECL. */ if (cp_unevaluated_operand != 0) return true; |