https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87957
Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |hubicka at gcc dot gnu.org --- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> --- There's patch candidate: diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c index 4676bdbdf93..71cd35caf0c 100644 --- a/gcc/ipa-devirt.c +++ b/gcc/ipa-devirt.c @@ -1048,7 +1048,11 @@ warn_odr (tree t1, tree t2, tree st1, tree st2, } else return; - inform (DECL_SOURCE_LOCATION (decl2), reason); + + location_t loc = (TYPE_NAME (t1) && TREE_CODE (TYPE_NAME (t1)) == TYPE_DECL + ? DECL_SOURCE_LOCATION (TYPE_NAME (t1)) + : UNKNOWN_LOCATION); + inform (loc, reason); if (warned) *warned = true; But now I see repeated Wodr: $ g++ -flto [12].ii -shared 1.ii:3:3: warning: type ‘struct YYSTYPE’ violates the C++ One Definition Rule [-Wodr] 3 | } YYSTYPE; | ^ 1.ii:3:3: note: a type with different alignment is defined in another translation unit 1.ii:4:7: warning: type ‘union yyalloc’ violates the C++ One Definition Rule [-Wodr] 4 | union yyalloc { | ^ 1.ii:4:7: note: a different type is defined in another translation unit 1.ii:6:11: note: the first difference of corresponding definitions is field ‘yyvs’ 6 | YYSTYPE yyvs; | ^ 1.ii:4:7: note: a field of same name but different type is defined in another translation unit 4 | union yyalloc { | ^ 1.ii:3:3: note: type ‘struct YYSTYPE’ itself violates the C++ One Definition Rule 3 | } YYSTYPE; | ^ 1.ii:3:3: warning: type ‘struct YYSTYPE’ violates the C++ One Definition Rule [-Wodr] 2.ii:1:16: note: a different type is defined in another translation unit 1 | typedef struct YYSTYPE { | ^ 1.ii:2:7: note: the first difference of corresponding definitions is field ‘a’ 2 | int a; | ^ 1.ii:3:3: note: a type with different number of fields is defined in another translation unit 3 | } YYSTYPE; | ^ Leaving to Honza.