diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index ab5cb69b2ae..71d33d2b7a4 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -12478,18 +12478,14 @@ grokdeclarator (const cp_declarator *declarator,
 	{
 	  if (typedef_decl)
 	    {
-	      pedwarn (loc, OPT_Wpedantic, "%qs specified with %qD",
+	      pedwarn (loc, OPT_Wpedantic,
+		       "%qs specified with typedef-name %qD",
 		       key, typedef_decl);
 	      ok = !flag_pedantic_errors;
+	      /* PR108099: __int128_t comes from c_common_nodes_and_builtins,
+		 and is not built as a typedef.  */
 	      if (is_typedef_decl (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);
+		type = DECL_ORIGINAL_TYPE (typedef_decl);
 	    }
 	  else if (declspecs->decltype_p)
 	    error_at (loc, "%qs specified with %<decltype%>", key);
@@ -12542,7 +12538,7 @@ grokdeclarator (const cp_declarator *declarator,
       else if (type == char_type_node)
 	type = unsigned_char_type_node;
       else if (typedef_decl)
-	type = unsigned_type_for (type);
+	type = c_common_unsigned_type (type);
       else
 	type = unsigned_type_node;
     }
@@ -12556,6 +12552,8 @@ grokdeclarator (const cp_declarator *declarator,
     type = long_integer_type_node;
   else if (short_p)
     type = short_integer_type_node;
+  else if (signed_p && typedef_decl)
+    type = c_common_signed_type (type);
 
   if (decl_spec_seq_has_spec_p (declspecs, ds_complex))
     {
diff --git a/gcc/testsuite/g++.dg/ext/int128-8.C b/gcc/testsuite/g++.dg/ext/int128-8.C
index 7e909d50873..07535a9820e 100644
--- a/gcc/testsuite/g++.dg/ext/int128-8.C
+++ b/gcc/testsuite/g++.dg/ext/int128-8.C
@@ -16,8 +16,8 @@ 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 (is_same <unsigned __int128, u128>::value, "");
+static_assert (is_same <__uint128_t, u128>::value, "");
 static_assert (sizeof (s128) == sizeof (__int128), "");
 static_assert (sizeof (u128) == sizeof (unsigned __int128), "");
 static_assert (s128(-1) < 0, "");
diff --git a/gcc/testsuite/g++.dg/ext/unsigned-typedef2.C b/gcc/testsuite/g++.dg/ext/unsigned-typedef2.C
new file mode 100644
index 00000000000..936c0ccb748
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/unsigned-typedef2.C
@@ -0,0 +1,25 @@
+// PR c++/108099
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+typedef long long t64;
+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 {};
+
+using s64 = signed t64;
+static_assert (is_same <long long, s64>::value, "");
+static_assert (is_same <signed long long, s64>::value, "");
+static_assert (sizeof (s64) == sizeof (long long), "");
+static_assert (s64(-1) < 0, "");
+
+using u64 = unsigned t64;
+static_assert (is_same <unsigned long long, u64>::value, "");
+static_assert (sizeof (u64) == sizeof (unsigned long long), "");
+static_assert (u64(-1) > 0, "");
diff --git a/gcc/testsuite/g++.dg/ext/unsigned-typedef3.C b/gcc/testsuite/g++.dg/ext/unsigned-typedef3.C
new file mode 100644
index 00000000000..bb99ca0ccc9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/unsigned-typedef3.C
@@ -0,0 +1,25 @@
+// PR c++/108099
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+typedef unsigned long long t64;
+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 {};
+
+using s64 = signed t64;
+static_assert (is_same <long long, s64>::value, "");
+static_assert (is_same <signed long long, s64>::value, "");
+static_assert (sizeof (s64) == sizeof (long long), "");
+static_assert (s64(-1) < 0, "");
+
+using u64 = unsigned t64;
+static_assert (is_same <unsigned long long, u64>::value, "");
+static_assert (sizeof (u64) == sizeof (unsigned long long), "");
+static_assert (u64(-1) > 0, "");
