@@ -2610,10 +2610,13 @@ cp_tree_equal (tree t1, tree t2)
tree o1 = TREE_OPERAND (t1, 0);
tree o2 = TREE_OPERAND (t2, 0);
- if (SIZEOF_EXPR_TYPE_P (t1))
- o1 = TREE_TYPE (o1);
- if (SIZEOF_EXPR_TYPE_P (t2))
- o2 = TREE_TYPE (o2);
+ if (code1 == SIZEOF_EXPR)
+ {
+ if (SIZEOF_EXPR_TYPE_P (t1))
+ o1 = TREE_TYPE (o1);
+ if (SIZEOF_EXPR_TYPE_P (t2))
+ o2 = TREE_TYPE (o2);
+ }
if (TREE_CODE (o1) != TREE_CODE (o2))
return false;
if (TYPE_P (o1))
@@ -0,0 +1,9 @@
+// PR c++/55337
+// { dg-do compile }
+
+template <int> struct A;
+template <typename T> struct B
+{
+ static A <__alignof__ (T)> b;
+};
+template <typename T> A<__alignof__ (T)> B<T>::b;