public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-9447] c++: fix 'unsigned __int128_t' semantics [PR108099]
@ 2023-04-19 16:53 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2023-04-19 16:53 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7b30f13b904f137c77e5180357af7917a3b47af0

commit r12-9447-g7b30f13b904f137c77e5180357af7917a3b47af0
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 18 17:12:17 2023 -0400

    c++: fix 'unsigned __int128_t' semantics [PR108099]
    
    My earlier patch for 108099 made us accept this non-standard pattern but
    messed up the semantics, so that e.g. unsigned __int128_t was not a 128-bit
    type.
    
            PR c++/108099
    
    gcc/cp/ChangeLog:
    
            * decl.cc (grokdeclarator): Keep typedef_decl for __int128_t.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/ext/int128-8.C: New test.

Diff:
---
 gcc/cp/decl.cc                      |  6 ++++--
 gcc/testsuite/g++.dg/ext/int128-8.C | 24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index cbb9f20b7a4..f514377dd42 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -12304,12 +12304,14 @@ grokdeclarator (const cp_declarator *declarator,
 		       key, typedef_decl);
 	      ok = !flag_pedantic_errors;
 	      if (is_typedef_decl (typedef_decl))
-		type = DECL_ORIGINAL_TYPE (typedef_decl);
+		{
+		  type = DECL_ORIGINAL_TYPE (typedef_decl);
+		  typedef_decl = NULL_TREE;
+		}
 	      else
 		/* PR108099: __int128_t comes from c_common_nodes_and_builtins,
 		   and is not built as a typedef.  */
 		type = TREE_TYPE (typedef_decl);
-	      typedef_decl = NULL_TREE;
 	    }
 	  else if (declspecs->decltype_p)
 	    error_at (loc, "%qs specified with %<decltype%>", key);
diff --git a/gcc/testsuite/g++.dg/ext/int128-8.C b/gcc/testsuite/g++.dg/ext/int128-8.C
new file mode 100644
index 00000000000..14bbc49f5c3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/int128-8.C
@@ -0,0 +1,24 @@
+// PR c++/108099
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+using u128 = unsigned __int128_t;
+using s128 = signed __int128_t;
+template <typename T, T v> struct integral_constant {
+  static constexpr T value = v;
+};
+typedef integral_constant <bool, false> false_type;
+typedef integral_constant <bool, true> true_type;
+template <class T, class U>
+struct is_same : false_type {};
+template <class T>
+struct is_same <T, T> : true_type {};
+static_assert (is_same <__int128, s128>::value, "");
+static_assert (is_same <signed __int128, s128>::value, "");
+static_assert (is_same <__int128_t, s128>::value, "");
+static_assert (is_same <unsigned __int128, u128>::value, ""); // { dg-bogus "" "" { xfail *-*-* } }
+static_assert (is_same <__uint128_t, u128>::value, "");	      // { dg-bogus "" "" { xfail *-*-* } }
+static_assert (sizeof (s128) == sizeof (__int128), "");
+static_assert (sizeof (u128) == sizeof (unsigned __int128), "");
+static_assert (s128(-1) < 0, "");
+static_assert (u128(-1) > 0, "");

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-19 16:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-19 16:53 [gcc r12-9447] c++: fix 'unsigned __int128_t' semantics [PR108099] Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).