aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/decl2.cc')
-rw-r--r--gcc/cp/decl2.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
index 2bbc618..6499be1 100644
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3. If not see
#include "omp-general.h"
#include "tree-inline.h"
#include "escaped_string.h"
+#include "contracts.h"
/* Id for dumping the raw trees. */
int raw_dump_id;
@@ -6229,6 +6230,7 @@ cp_warn_deprecated_use_scopes (tree scope)
bool
decl_dependent_p (tree decl)
{
+ tree orig_decl = decl;
if (DECL_FUNCTION_SCOPE_P (decl)
|| TREE_CODE (decl) == CONST_DECL
|| TREE_CODE (decl) == USING_DECL
@@ -6240,6 +6242,13 @@ decl_dependent_p (tree decl)
if (LAMBDA_FUNCTION_P (decl)
&& dependent_type_p (DECL_CONTEXT (decl)))
return true;
+ /* for-range-declaration of expansion statement as well as variable
+ declarations in the expansion statement body when the expansion statement
+ is not inside a template still need to be treated as dependent during
+ parsing. When the body is instantiated, in_expansion_stmt will be already
+ false. */
+ if (VAR_P (orig_decl) && in_expansion_stmt && decl == current_function_decl)
+ return true;
return false;
}