view gcc/testsuite/g++.dg/init/pr88375-2.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line source

// { dg-do compile { target c++11 } }
// { dg-options "-fdiagnostics-show-caret" }

enum struct a : int {
  one, two
};

constexpr int fn () { return 42; }

struct foo {
  int e1, e2;
  a e3;
} arr[] = {
  { 3, a::two }, // { dg-error "11: cannot convert 'a' to 'int' in initialization" }
  /* { dg-begin-multiline-output "" }
   { 3, a::two },
        ~~~^~~
           |
           a
     { dg-end-multiline-output "" } */
  { 6, 7, fn() }, // { dg-error "13: cannot convert 'int' to 'a' in initialization" }
  /* { dg-begin-multiline-output "" }
   { 6, 7, fn() },
           ~~^~
             |
             int
     { dg-end-multiline-output "" } */
};

struct bar {
  const char *f1;
  int f2;
} arr_2[] = {
  { 42 }, // { dg-error "5: invalid conversion from 'int' to 'const char\\*'" }
  /* { dg-begin-multiline-output "" }
   { 42 },
     ^~
     |
     int
     { dg-end-multiline-output "" } */
};