From: Paolo Carlini Date: Wed, 12 Nov 2014 20:43:09 +0000 (+0000) Subject: DR 1510 PR c++/60420 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=186ad798b9f039e5c824636687d0ee67f29bfc80;p=gcc.git DR 1510 PR c++/60420 /cp 2014-11-12 Paolo Carlini DR 1510 PR c++/60420 * cp-tree.h (struct cp_decl_specifier_seq): Add decltype_p bool field. * decl.c (grokdeclarator): Use it. * parser.c (cp_parser_simple_type_specifier): Likewise. * pt.c (tsubst, case DECLTYPE_TYPE): Use tf_ignore_bad_quals. /testsuite 2014-11-12 Paolo Carlini DR 1510 PR c++/60420 * g++.dg/cpp0x/decltype61.C: New. From-SVN: r217444 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a5513b6cf45..abb9ffb2380 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2014-11-12 Paolo Carlini + + DR 1510 + PR c++/60420 + * cp-tree.h (struct cp_decl_specifier_seq): Add decltype_p bool field. + * decl.c (grokdeclarator): Use it. + * parser.c (cp_parser_simple_type_specifier): Likewise. + * pt.c (tsubst, case DECLTYPE_TYPE): Use tf_ignore_bad_quals. + 2014-11-11 Paolo Carlini PR c++/63265 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 74636dfbf8f..82243609870 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4933,6 +4933,8 @@ typedef struct cp_decl_specifier_seq { BOOL_BITFIELD explicit_char_p : 1; /* True iff ds_thread is set for __thread, not thread_local. */ BOOL_BITFIELD gnu_thread_keyword_p : 1; + /* True iff the type is a decltype. */ + BOOL_BITFIELD decltype_p : 1; } cp_decl_specifier_seq; /* The various kinds of declarators. */ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 4abc1011e61..9ca32e37d95 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9421,7 +9421,8 @@ grokdeclarator (const cp_declarator *declarator, type_quals |= cp_type_quals (type); type = cp_build_qualified_type_real - (type, type_quals, ((typedef_decl && !DECL_ARTIFICIAL (typedef_decl) + (type, type_quals, ((((typedef_decl && !DECL_ARTIFICIAL (typedef_decl)) + || declspecs->decltype_p) ? tf_ignore_bad_quals : 0) | tf_warning_or_error)); /* We might have ignored or rejected some of the qualifiers. */ type_quals = cp_type_quals (type); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e1b320ab1ab..93520bc4ecf 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -14903,9 +14903,15 @@ cp_parser_simple_type_specifier (cp_parser* parser, { type = token->u.value; if (decl_specs) - cp_parser_set_decl_spec_type (decl_specs, type, - token, - /*type_definition_p=*/false); + { + cp_parser_set_decl_spec_type (decl_specs, type, + token, + /*type_definition_p=*/false); + /* Remember that we are handling a decltype in order to + implement the resolution of DR 1510 when the argument + isn't instantiation dependent. */ + decl_specs->decltype_p = true; + } cp_lexer_consume_token (parser->lexer); return type; } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 21d4039b623..f408680abbf 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12462,7 +12462,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) return cp_build_qualified_type_real (type, cp_type_quals (t) | cp_type_quals (type), - complain); + complain | tf_ignore_bad_quals); } case UNDERLYING_TYPE: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3c53939083b..d943df62a0f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-11-12 Paolo Carlini + + DR 1510 + PR c++/60420 + * g++.dg/cpp0x/decltype61.C: New. + 2014-11-12 H.J. Lu PR tree-optimization/63835 diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype61.C b/gcc/testsuite/g++.dg/cpp0x/decltype61.C new file mode 100644 index 00000000000..0159330d79c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/decltype61.C @@ -0,0 +1,20 @@ +// DR 1510, PR c++/60420 +// { dg-do compile { target c++11 } } + +struct MyIter +{ + int& operator*(); +}; + +void foo(MyIter begin) +{ + auto x = [](const decltype(*begin)) { }; +} + +template +void bar(Iterator begin) +{ + auto x = [](const decltype(*begin)) { }; +} + +template void bar(MyIter);