1  /* PR43651 */
       2  /* { dg-do compile } */
       3  /* { dg-options "-Wduplicate-decl-specifier" } */
       4  
       5  typedef const int CT1;
       6  #define CT2 const int
       7  typedef volatile int VT1;
       8  #define VT2 volatile int
       9  typedef char *restrict RT1;
      10  #define RT2 char *restrict
      11  
      12  void
      13  foo (void)
      14  {
      15    const CT1 x1;
      16    const CT2 x2;
      17    CT1 const x3;
      18    CT2 const x4;
      19    const int const x5; /* { dg-warning "duplicate .const." } */
      20    const int *const x6;
      21    volatile VT1 y1;
      22    volatile VT2 y2;
      23    VT1 volatile y3;
      24    VT2 volatile y4;
      25    volatile int volatile y5; /* { dg-warning "duplicate .volatile." } */
      26    volatile int *volatile y6;
      27    RT1 restrict r1;
      28    RT2 restrict r2;
      29    restrict RT1 r3;
      30    /* "restrict RT2" is invalid */
      31    char *restrict restrict r4; /* { dg-warning "duplicate .restrict." } */
      32    char *restrict *restrict r5;
      33  }
      34  
      35  void c1(const CT1 t) { }
      36  void c2(const CT2 t) { }
      37  void c3(CT1 const t) { }
      38  void c4(CT2 const t) { }
      39  void c5(const int const t) { }  /* { dg-warning "duplicate .const." } */
      40  void v1(volatile VT1 t) { }
      41  void v2(volatile VT2 t) { }
      42  void v3(VT1 volatile t) { }
      43  void v4(VT2 volatile t) { }
      44  void v5(volatile int volatile t) { } /* { dg-warning "duplicate .volatile." } */
      45  void r1(restrict RT1 t) { }
      46  void r2(RT1 restrict t) { }
      47  void r3(RT2 restrict t) { }
      48  void r4(char *restrict restrict t) { }  /* { dg-warning "duplicate .restrict." } */
      49  
      50  typedef const CT1 CCT1;
      51  typedef const CT2 CCT2;
      52  typedef CT1 const CT1C;
      53  typedef CT2 const CT2C;
      54  typedef const int const CIC;    /* { dg-warning "duplicate .const." } */
      55  typedef volatile VT1 VVT1;
      56  typedef volatile VT2 VVT2;
      57  typedef VT1 volatile VT1V;
      58  typedef VT2 volatile VT2V;
      59  typedef volatile int volatile VIV; /* { dg-warning "duplicate .volatile." } */
      60  typedef RT1 restrict RT1R;
      61  typedef RT2 restrict RT2R;
      62  typedef restrict RT1 RRT1;
      63  typedef int *restrict restrict IRR; /* { dg-warning "duplicate .restrict." } */