192906Smarkm// { dg-do assemble  }
292906Smarkm// Copyright (C) 1999 Free Software Foundation, Inc.
322347Spst// Contributed by Nathan Sidwell 12 Dec 1999 <nathan@acm.org>
422347Spst
522347Spst// static_cast should not cast _away_ constness ([expr.static.cast]/6),
622347Spst// but nothing bans _adding_ constness. [expr.static.cast]/10 states that a
722347Spst// pointer of type cv void can be cast to pointer to object type.
822347Spst
922347Spststruct X;
1022347Spststruct Y {};
1122347Spststruct Z : Y {};
1222347Spst
1322347Spstvoid fn (void *p, void const *cp, Y *yp, Y const *ycp, Z *zp, Z const *zcp)
1422347Spst{
1522347Spst  static_cast <X *> (p);
1622347Spst  static_cast <X const *> (p);
1722347Spst  static_cast <int *> (p);
1822347Spst  static_cast <int const *> (p);
1922347Spst  static_cast <int **> (p);
2022347Spst  static_cast <int const **> (p);
2122347Spst  static_cast <int *const *> (p);
2222347Spst  static_cast <int const *const *> (p);
2322347Spst
2422347Spst  static_cast <X *> (cp);           // { dg-error "" } lose const
2522347Spst  static_cast <X const *> (cp);
2622347Spst  static_cast <int *> (cp);         // { dg-error "" } lose const
2722347Spst  static_cast <int const *> (cp);
2822347Spst  static_cast <int **> (cp);        // { dg-error "" } lose const
2992906Smarkm  static_cast <int const **> (cp);  // { dg-error "" } lose const
3092906Smarkm  static_cast <int *const *> (cp);
3192906Smarkm  static_cast <int const *const *> (cp);
3229964Sache
3329964Sache  static_cast <Z *> (yp);
3429964Sache  static_cast <Z const *> (yp);
3592906Smarkm
3692906Smarkm  static_cast <Z *> (ycp);          // { dg-error "" } lose const
3792906Smarkm  static_cast <Z const *> (ycp);
3892906Smarkm
3992906Smarkm  static_cast <Y *> (zp);
4092906Smarkm  static_cast <Y const *> (zp);
4192906Smarkm
4292906Smarkm  static_cast <Y *> (zcp);          // { dg-error "" } lose const
4392906Smarkm  static_cast <Y const *> (zcp);
4492906Smarkm}
4592906Smarkm