re PR c++/52869 ([DR 1207] "this" not being allowed in noexcept clauses)
authorKamlesh Kumar <kamleshbhalui@gmail.com>
Fri, 16 Nov 2018 21:55:00 +0000 (21:55 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 16 Nov 2018 21:55:00 +0000 (16:55 -0500)
PR c++/52869

DR 1207
* parser.c (cp_parser_noexcept_specification_opt): Call
inject_this_parameter.

From-SVN: r266224

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/g++.dg/DRs/dr1207-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/DRs/dr1207-2.C [new file with mode: 0644]

index d0a344eadcaf1ad35fde8705b2445a48be598d96..6d99d6a5d79fd4c8284e3f4029611defb84d6edd 100644 (file)
@@ -1,3 +1,10 @@
+2018-11-16  Kamlesh Kumar  <kamleshbhalui@gmail.com>
+
+       DR 1207
+       PR c++/52869
+       * parser.c (cp_parser_noexcept_specification_opt): Call
+       inject_this_parameter.
+
 2018-11-16  Jason Merrill  <jason@redhat.com>
 
        Implement P0479R5, [[likely]] and [[unlikely]].
index 215c5fb9983287ef2899eb78a9c9294b1c42c4e8..88fc426102b04168273b69ac14e5fc5576821caa 100644 (file)
@@ -24668,6 +24668,12 @@ cp_parser_noexcept_specification_opt (cp_parser* parser,
          matching_parens parens;
          parens.consume_open (parser);
 
+         tree save_ccp = current_class_ptr;
+         tree save_ccr = current_class_ref;
+
+         if (current_class_type)
+           inject_this_parameter (current_class_type, TYPE_UNQUALIFIED);
+
          if (require_constexpr)
            {
              /* Types may not be defined in an exception-specification.  */
@@ -24687,6 +24693,9 @@ cp_parser_noexcept_specification_opt (cp_parser* parser,
            }
 
          parens.require_close (parser);
+
+         current_class_ptr = save_ccp;
+         current_class_ref = save_ccr;
        }
       else
        {
diff --git a/gcc/testsuite/g++.dg/DRs/dr1207-1.C b/gcc/testsuite/g++.dg/DRs/dr1207-1.C
new file mode 100644 (file)
index 0000000..16fce84
--- /dev/null
@@ -0,0 +1,23 @@
+// DR 1207
+// PR c++/52869
+// { dg-do compile { target c++11 } }
+
+struct S {
+    void f() { }
+    void g() noexcept(noexcept(f())) { }
+    void h() noexcept(noexcept(this->f())) { }
+};
+
+struct Nyan {
+       Nyan &operator++() noexcept { return *this; }
+       void omg() noexcept(noexcept(++*this)) {}
+};
+
+template <class T>
+class Test{
+    T count;
+    Test (T arg) {count=arg;}
+    void fetch() { }
+    T inc () noexcept(noexcept(this->fetch())) {return ++count;}
+    T dec () noexcept(noexcept(fetch())) { return --count;} 
+};
diff --git a/gcc/testsuite/g++.dg/DRs/dr1207-2.C b/gcc/testsuite/g++.dg/DRs/dr1207-2.C
new file mode 100644 (file)
index 0000000..2d54748
--- /dev/null
@@ -0,0 +1,12 @@
+// DR 1207
+// PR c++/52869
+// { dg-do compile { target c++11 } }
+
+void
+fn ()
+{
+  struct S {
+    bool operator!() noexcept(false);
+  } s;
+  S t = s;
+}