class.c (fixed_type_or_null): Handle NSDMI.
authorJason Merrill <jason@redhat.com>
Sun, 2 Oct 2011 21:44:52 +0000 (17:44 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 2 Oct 2011 21:44:52 +0000 (17:44 -0400)
* class.c (fixed_type_or_null): Handle NSDMI.
* method.c (walk_field_subobs): Disable NSDMI noexcept checking
for now.

From-SVN: r179435

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/method.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/nsdmi5.C [new file with mode: 0644]

index e9173050249c413681711116b6adf7483e68261c..a605c9fc32de8e9cc4bd472b68781ebcacc52148 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-02  Jason Merrill  <jason@redhat.com>
+
+       * class.c (fixed_type_or_null): Handle NSDMI.
+       * method.c (walk_field_subobs): Disable NSDMI noexcept checking
+       for now.
+
 2011-09-30  Jason Merrill  <jason@redhat.com>
 
        * cp-tree.h (TREE_NEGATED_INT): Remove.
index a7d8218055facebf3b35cbad149337b11cafa55a..2df9177e47edc818106af62866b98d373e1b9ffd 100644 (file)
@@ -6062,10 +6062,13 @@ fixed_type_or_null (tree instance, int *nonnull, int *cdtorp)
          if (nonnull)
            *nonnull = 1;
 
-         /* if we're in a ctor or dtor, we know our type.  */
-         if (DECL_LANG_SPECIFIC (current_function_decl)
-             && (DECL_CONSTRUCTOR_P (current_function_decl)
-                 || DECL_DESTRUCTOR_P (current_function_decl)))
+         /* if we're in a ctor or dtor, we know our type.  If
+            current_class_ptr is set but we aren't in a function, we're in
+            an NSDMI (and therefore a constructor).  */
+         if (current_scope () != current_function_decl
+             || (DECL_LANG_SPECIFIC (current_function_decl)
+                 && (DECL_CONSTRUCTOR_P (current_function_decl)
+                     || DECL_DESTRUCTOR_P (current_function_decl))))
            {
              if (cdtorp)
                *cdtorp = 1;
index 1316dfb6a8382662b823bbef157531090d72662f..f4a3ea6ac99d9c2c234d77017d7e66e7e98b4790 100644 (file)
@@ -1042,12 +1042,16 @@ walk_field_subobs (tree fields, tree fnname, special_function_kind sfk,
                inform (0, "initializer for %q+#D is invalid", field);
              if (trivial_p)
                *trivial_p = false;
+#if 0
              /* Core 1351: If the field has an NSDMI that could throw, the
                 default constructor is noexcept(false).  FIXME this is
-                broken by deferred parsing and 1360 saying we can't
-                lazily declare a non-trivial default constructor.  */
+                broken by deferred parsing and 1360 saying we can't lazily
+                declare a non-trivial default constructor.  Also this
+                needs to do deferred instantiation.  Disable until the
+                conflict between 1351 and 1360 is resolved.  */
              if (spec_p && !expr_noexcept_p (DECL_INITIAL (field), complain))
                *spec_p = noexcept_false_spec;
+#endif
 
              /* Don't do the normal processing.  */
              continue;
index 0f09e0f58f8bf809c34392541dd5e4e51f41d588..c4cadf732bfacf61bf18d32e4df478587c7b406d 100644 (file)
@@ -1,3 +1,7 @@
+2011-10-02  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/nsdmi5.C: New.
+
 2011-10-02  Richard Sandiford  <rdsandiford@googlemail.com>
 
        PR target/50579
diff --git a/gcc/testsuite/g++.dg/cpp0x/nsdmi5.C b/gcc/testsuite/g++.dg/cpp0x/nsdmi5.C
new file mode 100644 (file)
index 0000000..62803b0
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-options -std=c++0x }
+
+struct X
+{
+  int x = 5;
+  int f() { return x; }
+};
+struct Y : X
+{
+  int y = this->x;
+};
+template <class T> struct Z : T
+{
+  int y = this->f();
+};
+int main()
+{
+  Y foo;
+  Z<X> bar;
+}