(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
c2x-constexpr-2a.c
       1  /* Test C2x constexpr.  Valid code, execution test.  */
       2  /* { dg-do link } */
       3  /* { dg-options "-std=c2x -pedantic-errors" } */
       4  /* { dg-additional-sources "c2x-constexpr-2b.c" } */
       5  
       6  extern void abort (void);
       7  extern void exit (int);
       8  
       9  /* constexpr objects at file scope have internal linkage.  */
      10  constexpr int a = 2;
      11  
      12  struct s { int a; float b; int c[3]; };
      13  constexpr struct s s1 = { 2, 3, { 4, 5, 6 } };
      14  constexpr struct s s2 = s1;
      15  struct s s3 = s2;
      16  
      17  void
      18  check (const struct s *p)
      19  {
      20    if (p->a != 2 || p->b != 3 || p->c[0] != 4 || p->c[1] != 5 || p->c[2] != 6)
      21      abort ();
      22  }
      23  
      24  int
      25  main ()
      26  {
      27    constexpr struct s s4 = s1;
      28    struct s s5 = s4;
      29    constexpr struct s s6 = { s1.a, s2.b, { 4, 5, 6 } };
      30    check (&s1);
      31    check (&s2);
      32    check (&s3);
      33    check (&s4);
      34    check (&s5);
      35    check (&s6);
      36    exit (0);
      37  }