summaryrefslogtreecommitdiffstats
path: root/gcc/testsuite/gcc.dg/nested-func-8.c
diff options
context:
space:
mode:
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-30 11:43:02 +0000
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-30 11:43:02 +0000
commit7e3d3ba64fc63800a4f465d17d9b99ff76232213 (patch)
tree0b68390326b658c1ca86316a8dc1f8b29617d095 /gcc/testsuite/gcc.dg/nested-func-8.c
parent346b240d6c22e13b7a9bbbad566c6c4c9a5199f3 (diff)
downloadppe42-gcc-7e3d3ba64fc63800a4f465d17d9b99ff76232213.tar.gz
ppe42-gcc-7e3d3ba64fc63800a4f465d17d9b99ff76232213.zip
Fix location for static class members
Consider the test case g++.dg/other/offsetof5.C: #include <stddef.h> struct A { char c; int &i; }; int j = offsetof (A, i); // { dg-warning "invalid access|offsetof" } template <typename T> struct S { T h; T &i; static const int j = offsetof (S, i); // { dg-warning "invalid access|offsetof" } }; int k = S<int>::j; // { dg-message "required from here" } The second warning (that involves the instantiation of the S template) is not emitted when -ftrack-macro-expansion is on. This is because during the instantiation of the member j of S template, the location that is used for the warning is the one for the DECL j (set by instantiate_decl). And that location is inaccurately set to the locus of 'offsetof', which is a macro defined in a system header, so it's discarded by the diagnostics machinery. Note that when we reach the point where we emit the warning in build_class_member_access_expr offsetof expression has long been folded, so we cannot use e.g, the location of the ')' token that would have been in the source code. So I believe the location of 'j' is the best we can get at this point. The patch below sets the location of the DECL for 'j' to what I believe is its precise location; with that, the test case passes with and without -ftrack-macro-expansion. But I had to adjust g++.dg/template/sfinae6_neg.C for that. Tested on x86_64-unknown-linux-gnu against trunk. gcc/cp * decl.c (grokdeclarator): Use the location carried by the declarator for the DECL of the static class member. gcc/testsuite/ * g++.dg/template/sfinae6_neg.C: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186974 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/nested-func-8.c')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud