DR 1510 PR c++/60420
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 12 Nov 2014 20:43:09 +0000 (20:43 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 12 Nov 2014 20:43:09 +0000 (20:43 +0000)
/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

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype61.C [new file with mode: 0644]

index a5513b6cf45e18681cca3ca33c1f13e465aee9ae..abb9ffb23801ff40b2ffab7f26354285e43c0b68 100644 (file)
@@ -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
index 74636dfbf8f15be10875f703a1251dcb30fe7c4a..82243609870d45eb85f56e1ad51fec0a875397c8 100644 (file)
@@ -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.  */
index 4abc1011e61e453194f19d9066e26c38628bbe44..9ca32e37d9532d1cd1a3008f506b9276507bfa28 100644 (file)
@@ -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);
index e1b320ab1abc4508c161fbd8c362f8215f754774..93520bc4ecf72e6ec9f4b872990098f5ef632a93 100644 (file)
@@ -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;
     }
index 21d4039b62332c214453e90c23180452c9d56da3..f408680abbf86c0a8f7f3c02b2c26d2fae5adafa 100644 (file)
@@ -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:
index 3c53939083b8c212297fde7ccaede48ee1de6539..d943df62a0ff66b1725e96c6250ca4b121820bbf 100644 (file)
@@ -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 (file)
index 0000000..0159330
--- /dev/null
@@ -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);