Message ID | CAGqc0-pZN04jgDsJMutn09uxm5CrSejFAFkRANo=RmWW-YU4=g@mail.gmail.com |
---|---|
State | New |
Headers | show |
Hi, I'm going to ping this one too: a tad less trivial than the other one - a little explanation here or in a comment would definitely help - but certainly it looks much simpler than my own tries a while ago... Regression testing information is also missing. Thanks, Paolo. On 02/21/2015 01:12 PM, Andrea Azzarone wrote: > Hi all, > > please find attached a fix for pr 65071 "decltype(~arg) fails for > template functions". Basically we need to make sure that ~arg is > considered an expression and not a dtor. > > 2015-02-21 Andrea Azzarone <azzaronea@gmail.com> > PR c++/65091 > * parser.c (cp_parser_decltype_expr): Make sure ~id is treated as an > expression. > > >
On 07/11/2015 09:46 PM, Paolo Carlini wrote: > Hi, > > I'm going to ping this one too: a tad less trivial than the other one > - a little explanation here or in a comment would definitely help - > but certainly it looks much simpler than my own tries a while ago... > Regression testing information is also missing. ... in fact, one could argue that most of difference between Andrea's patch and my original try here: https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00821.html is mostly a matter of style + TYPE_P vs the narrower identifier_p... Paolo.
On 07/12/2015 01:53 PM, Paolo Carlini wrote: > On 07/11/2015 09:46 PM, Paolo Carlini wrote: >> I'm going to ping this one too: a tad less trivial than the other one >> - a little explanation here or in a comment would definitely help - >> but certainly it looks much simpler than my own tries a while ago... >> Regression testing information is also missing. > .... in fact, one could argue that most of difference between Andrea's > patch and my original try here: > > https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00821.html > > is mostly a matter of style + TYPE_P vs the narrower identifier_p... I'd prefer to fix this in the part of cp_parser_unqualified_id you quote; here ~x isn't really an unqualified-id, so we shouldn't treat it as one, at least when we're parsing tentatively. Jason
Hi, On 07/14/2015 09:10 PM, Jason Merrill wrote: > On 07/12/2015 01:53 PM, Paolo Carlini wrote: >> On 07/11/2015 09:46 PM, Paolo Carlini wrote: >>> I'm going to ping this one too: a tad less trivial than the other one >>> - a little explanation here or in a comment would definitely help - >>> but certainly it looks much simpler than my own tries a while ago... >>> Regression testing information is also missing. >> .... in fact, one could argue that most of difference between Andrea's >> patch and my original try here: >> >> https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00821.html >> >> is mostly a matter of style + TYPE_P vs the narrower identifier_p... > > I'd prefer to fix this in the part of cp_parser_unqualified_id you > quote; here ~x isn't really an unqualified-id, so we shouldn't treat > it as one, at least when we're parsing tentatively. I see. At the time I had this second try: https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01232.html which has the action in cp_parser_unqualified_id but unfortunately is more complex. Certainly we can't just return inconditionally error_mark_node in that case, we have at least these regressions, a few accepts-invalid: FAIL: g++.dg/parse/dtor14.C -std=c++98 (test for errors, line 7) FAIL: g++.dg/parse/dtor14.C -std=c++11 (test for errors, line 7) FAIL: g++.dg/parse/dtor14.C -std=c++14 (test for errors, line 7) FAIL: g++.dg/parse/dtor15.C -std=c++98 (test for errors, line 8) FAIL: g++.dg/parse/dtor15.C -std=c++98 (test for excess errors) FAIL: g++.dg/parse/dtor15.C -std=c++11 (test for errors, line 8) FAIL: g++.dg/parse/dtor15.C -std=c++11 (test for excess errors) FAIL: g++.dg/parse/dtor15.C -std=c++14 (test for errors, line 8) FAIL: g++.dg/parse/dtor15.C -std=c++14 (test for excess errors) FAIL: g++.dg/template/dtor5.C -std=c++98 (test for errors, line 14) FAIL: g++.dg/template/dtor5.C -std=c++11 (test for errors, line 14) FAIL: g++.dg/template/dtor5.C -std=c++14 (test for errors, line 14) FAIL: g++.dg/template/dtor7.C -std=c++98 (test for errors, line 15) XPASS: g++.dg/template/dtor7.C -std=c++98 (test for bogus messages, line 21) FAIL: g++.dg/template/dtor7.C -std=c++11 (test for errors, line 15) XPASS: g++.dg/template/dtor7.C -std=c++11 (test for bogus messages, line 21) FAIL: g++.dg/template/dtor7.C -std=c++14 (test for errors, line 15) XPASS: g++.dg/template/dtor7.C -std=c++14 (test for bogus messages, line 21) Do you think something simpler could work? Thanks! Paolo.
Index: gcc/cp/parser.c =================================================================== --- gcc/cp/parser.c (revision 220698) +++ gcc/cp/parser.c (working copy) @@ -12236,7 +12236,10 @@ cp_parser_decltype_expr (cp_parser *pars /*declarator_p=*/false, /*optional_p=*/false); - if (!cp_parser_error_occurred (parser) && expr != error_mark_node) + if (!cp_parser_error_occurred (parser) + && expr + && expr != error_mark_node + && (TREE_CODE (expr) != BIT_NOT_EXPR || TYPE_P (TREE_OPERAND (expr, 0)))) { bool non_integral_constant_expression_p = false; tree id_expression = expr; Index: gcc/testsuite/g++.dg/cpp0x/trailing10.C =================================================================== --- gcc/testsuite/g++.dg/cpp0x/trailing10.C (revision 0) +++ gcc/testsuite/g++.dg/cpp0x/trailing10.C (working copy) @@ -0,0 +1,11 @@ +// PR c++/65091 +// { dg-do compile { target c++11 } } + +template<typename T> +auto foo(T x) -> decltype(~x) { + return ~x; +} + +int bar() { + return foo(10); +}