Debian Codegraph @

gcc/testsuite/g++.dg/lto/odr-3_0.C

raw
1 // { dg-lto-do link }
2
3 typedef struct {
4 int a; // { dg-lto-message "the first difference of corresponding definitions is field 'a'" }
5 } YYSTYPE; // { dg-lto-message "violates the C\\+\\+ One Definition Rule" 2 }
6 // Here we get warning and a note:
7 // warning: type 'struct YYSTYPE' violates the C++ One Definition Rule
8 // note: type 'struct YYSTYPE' itself violates the C++ One Definition Rule
9 union yyalloc { // { dg-lto-warning "7: type 'union yyalloc' violates the C\\+\\+ One Definition Rule" }
10 short yyss;
11 YYSTYPE yyvs; // { dg-lto-message "the first difference of corresponding definitions is field 'yyvs'" }
12 };
13 extern yyalloc a; // { dg-lto-warning "16: 'a' violates the C\\+\\+ One Definition Rule" }
14 int
15 main (void) {return a.yyss;}
16
17 /* Match warnings as follows:
18 odr-3_0.C:5:3: warning: type 'struct YYSTYPE' violates the C++ One Definition Rule [-Wodr]
19 odr-3_1.C:1:16: note: a different type is defined in another translation unit^
20 odr-3_0.C:4:7: note: the first difference of corresponding definitions is field 'a'
21 odr-3_1.C:1:16: note: a type with different number of fields is defined in another translation unit
22 odr-3_0.C:9:7: warning: type 'union yyalloc' violates the C++ One Definition Rule [-Wodr]
23 odr-3_1.C:6:7: note: a different type is defined in another translation unit
24 odr-3_0.C:11:11: note: the first difference of corresponding definitions is field 'yyvs'
25 odr-3_1.C:11:11: note: a field of same name but different type is defined in another translation unit
26 odr-3_0.C:5:3: note: type 'struct YYSTYPE' itself violates the C++ One Definition Rule
27 odr-3_0.C:13:16: warning: 'a' violates the C++ One Definition Rule [-Wodr]
28 odr-3_1.C:6:7: note: type 'union yyalloc' itself violates the C++ One Definition Rule
29 odr-3_0.C:9:7: note: the incompatible type is defined here
30 odr-3_1.C:15:9: note: 'a' was previously declared here
31 odr-3_1.C:15:9: note: code may be misoptimized unless -fno-strict-aliasing is used
32 */