From b3ff651a97bc7d607608ec2e4750646332ad04a5 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 16 Jul 2012 17:25:30 -0400 Subject: [PATCH] cp-tree.h (struct deferred_access_check): Add location. * cp-tree.h (struct deferred_access_check): Add location. * semantics.c (perform_access_checks): Use it. (perform_or_defer_access_check): Store it. From-SVN: r189552 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/cp-tree.h | 2 ++ gcc/cp/semantics.c | 9 ++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/access8.C | 4 ++-- gcc/testsuite/g++.dg/template/sfinae6_neg.C | 4 ++-- 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a1326dde547..a8b19aec857 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-07-16 Jason Merrill + + * cp-tree.h (struct deferred_access_check): Add location. + * semantics.c (perform_access_checks): Use it. + (perform_or_defer_access_check): Store it. + 2012-07-16 Steven Bosscher * dump.c (dump_stmt): Moved here from c-dump.c. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 10efa2a663a..59104e7b094 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5484,6 +5484,8 @@ typedef struct GTY(()) deferred_access_check { tree decl; /* The declaration that should be used in the error message. */ tree diag_decl; + /* The location of this access. */ + location_t loc; } deferred_access_check; DEF_VEC_O(deferred_access_check); DEF_VEC_ALLOC_O(deferred_access_check,gc); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index a32e48aa049..81102959f23 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -259,12 +259,18 @@ perform_access_checks (VEC (deferred_access_check,gc)* checks) { int i; deferred_access_check *chk; + location_t loc = input_location; if (!checks) return; FOR_EACH_VEC_ELT (deferred_access_check, checks, i, chk) - enforce_access (chk->binfo, chk->decl, chk->diag_decl); + { + input_location = chk->loc; + enforce_access (chk->binfo, chk->decl, chk->diag_decl); + } + + input_location = loc; } /* Perform the deferred access checks. @@ -334,6 +340,7 @@ perform_or_defer_access_check (tree binfo, tree decl, tree diag_decl) new_access->binfo = binfo; new_access->decl = decl; new_access->diag_decl = diag_decl; + new_access->loc = input_location; } /* Used by build_over_call in LOOKUP_SPECULATIVE mode: return whether DECL diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1eebfa4d3bb..f0a13ab3c67 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-07-16 Jason Merrill + + * g++.dg/parse/access8.C: Adjust. + * g++.dg/template/sfinae6_neg.C: Adjust. + 2012-07-16 Thomas König PR fortran/53824 diff --git a/gcc/testsuite/g++.dg/parse/access8.C b/gcc/testsuite/g++.dg/parse/access8.C index 45f4be70288..205b7f2712a 100644 --- a/gcc/testsuite/g++.dg/parse/access8.C +++ b/gcc/testsuite/g++.dg/parse/access8.C @@ -5,8 +5,8 @@ class foo typedef int memfun; // { dg-error "private" } }; -template -struct fm_obj { }; // { dg-error "context" } +template // { dg-error "context" } +struct fm_obj { }; template // { dg-error "context" } struct S {}; diff --git a/gcc/testsuite/g++.dg/template/sfinae6_neg.C b/gcc/testsuite/g++.dg/template/sfinae6_neg.C index c238222af75..28adf73e9f3 100644 --- a/gcc/testsuite/g++.dg/template/sfinae6_neg.C +++ b/gcc/testsuite/g++.dg/template/sfinae6_neg.C @@ -14,14 +14,14 @@ template struct enable_if { }; template typename enable_if()(create_a(), create_a()), 1), yes_type>::type - check_is_callable2(type, type, type); + check_is_callable2(type, type, type); // { dg-error "within this context" } no_type check_is_callable2(...); template struct is_callable2 { - static const bool value = // { dg-error "within this context" } + static const bool value = (sizeof(check_is_callable2(type(), type(), type())) == sizeof(yes_type)); };