Hi,

On 09/21/2011 03:25 AM, Jason Merrill wrote:
On 09/20/2011 08:38 PM, Paolo Carlini wrote:
+      if (int128_integer_type_node == NULL_TREE)
+    error ("%<__int128%>  is not supported by this target");

In this case we should unset explicit_int128.

Also remove this code:

      else if (explicit_int128 && TREE_CODE (type) != INTEGER_TYPE)
        error ("%<__int128%> invalid for %qs", name);

and the modification of explicit_int128 here:

      /* Discard the type modifiers if they are invalid.  */
      if (! ok)
        {
          unsigned_p = false;
          signed_p = false;
          long_p = false;
          short_p = false;
          longlong = 0;
          explicit_int128 = false;
Ok. I'm going to test the below. Ok if it passes again?

Thanks,
Paolo.

////////////////////
Index: testsuite/g++.dg/ext/int128-1.C
===================================================================
--- testsuite/g++.dg/ext/int128-1.C     (revision 0)
+++ testsuite/g++.dg/ext/int128-1.C     (revision 0)
@@ -0,0 +1,11 @@
+// PR c++/50454
+// { dg-do compile { target int128 } }
+
+template<typename T>
+  struct limits;
+
+template<>
+  struct limits<__int128> { }; // { dg-error "does not support" }
+
+template<>
+  struct limits<unsigned __int128> { }; // { dg-error "does not support" }
Index: testsuite/g++.dg/ext/int128-2.C
===================================================================
--- testsuite/g++.dg/ext/int128-2.C     (revision 0)
+++ testsuite/g++.dg/ext/int128-2.C     (revision 0)
@@ -0,0 +1,4 @@
+// PR c++/50454
+// { dg-do compile { target int128 } }
+
+#include "int128-2.h"
Index: testsuite/g++.dg/ext/int128-2.h
===================================================================
--- testsuite/g++.dg/ext/int128-2.h     (revision 0)
+++ testsuite/g++.dg/ext/int128-2.h     (revision 0)
@@ -0,0 +1,10 @@
+#pragma GCC system_header
+
+template<typename T>
+  struct limits;
+
+template<>
+  struct limits<__int128> { };
+
+template<>
+  struct limits<unsigned __int128> { };
Index: cp/decl.c
===================================================================
--- cp/decl.c   (revision 179024)
+++ cp/decl.c   (working copy)
@@ -8640,6 +8640,18 @@ grokdeclarator (const cp_declarator *declarator,
 
   ctype = NULL_TREE;
 
+  if (explicit_int128)
+    {
+      if (int128_integer_type_node == NULL_TREE)
+       {
+         error ("%<__int128%> is not supported by this target");
+         explicit_int128 = false;
+       }
+      else if (pedantic && ! in_system_header)
+       pedwarn (input_location, OPT_pedantic,
+                "ISO C++ does not support %<__int128%> for %qs", name);
+    }
+
   /* Now process the modifiers that were specified
      and check for invalid combinations.  */
 
@@ -8663,8 +8675,6 @@ grokdeclarator (const cp_declarator *declarator,
        error ("%<signed%> and %<unsigned%> specified together for %qs", name);
       else if (longlong && TREE_CODE (type) != INTEGER_TYPE)
        error ("%<long long%> invalid for %qs", name);
-      else if (explicit_int128 && TREE_CODE (type) != INTEGER_TYPE)
-       error ("%<__int128%> invalid for %qs", name);
       else if (long_p && TREE_CODE (type) == REAL_TYPE)
        error ("%<long%> invalid for %qs", name);
       else if (short_p && TREE_CODE (type) == REAL_TYPE)
@@ -8695,22 +8705,6 @@ grokdeclarator (const cp_declarator *declarator,
              if (flag_pedantic_errors)
                ok = 0;
            }
-         if (explicit_int128)
-           {
-             if (int128_integer_type_node == NULL_TREE)
-               {
-                 error ("%<__int128%> is not supported by this target");
-                 ok = 0;
-               }
-             else if (pedantic)
-               {
-                 pedwarn (input_location, OPT_pedantic,
-                          "ISO C++ does not support %<__int128%> for %qs",
-                          name);
-                 if (flag_pedantic_errors)
-                   ok = 0;
-               }
-           }
        }
 
       /* Discard the type modifiers if they are invalid.  */
@@ -8721,7 +8715,6 @@ grokdeclarator (const cp_declarator *declarator,
          long_p = false;
          short_p = false;
          longlong = 0;
-         explicit_int128 = false;
        }
     }
 

Reply via email to