diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2014-11-12 20:43:09 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2014-11-12 20:43:09 +0000 |
commit | 186ad798b9f039e5c824636687d0ee67f29bfc80 (patch) | |
tree | 37b754ad44204cc97f4a58e07513379bf4250128 /gcc | |
parent | 7eb0def89e57086611a044febf906ffd3e515c3a (diff) | |
download | gcc-186ad798b9f039e5c824636687d0ee67f29bfc80.zip gcc-186ad798b9f039e5c824636687d0ee67f29bfc80.tar.gz gcc-186ad798b9f039e5c824636687d0ee67f29bfc80.tar.bz2 |
DR 1510 PR c++/60420
/cp
2014-11-12 Paolo Carlini <paolo.carlini@oracle.com>
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 <paolo.carlini@oracle.com>
DR 1510
PR c++/60420
* g++.dg/cpp0x/decltype61.C: New.
From-SVN: r217444
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/decl.c | 3 | ||||
-rw-r--r-- | gcc/cp/parser.c | 12 | ||||
-rw-r--r-- | gcc/cp/pt.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/decltype61.C | 20 |
7 files changed, 49 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a5513b6..abb9ffb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2014-11-12 Paolo Carlini <paolo.carlini@oracle.com> + + 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 <paolo.carlini@oracle.com> PR c++/63265 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 74636df..8224360 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 4abc101..9ca32e3 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 e1b320a..93520bc 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 21d4039..f408680 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 3c53939..d943df6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2014-11-12 Paolo Carlini <paolo.carlini@oracle.com> + + DR 1510 + PR c++/60420 + * g++.dg/cpp0x/decltype61.C: New. + 2014-11-12 H.J. Lu <hongjiu.lu@intel.com> 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 0000000..0159330 --- /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<typename Iterator> +void bar(Iterator begin) +{ + auto x = [](const decltype(*begin)) { }; +} + +template void bar<MyIter>(MyIter); |