Avoid infinite loop with duplicate anonymous union fields (PR c/86690).
commit40eafc9b51049b4626ab34565c5b263e580738cd
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 Aug 2018 15:25:35 +0000 (3 15:25 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 Aug 2018 15:25:35 +0000 (3 15:25 +0000)
tree976a94aedd0a8d55a01a8027541c47a938e0e252
parent960639dc9a23db586d10319a5368d218d5171368
Avoid infinite loop with duplicate anonymous union fields (PR c/86690).

If a struct contains an anonymous union and both have a field with the
same name, detect_field_duplicates_hash() will replace one of them
with NULL.  If compilation doesn't stop immediately, it may later call
lookup_field() on the union, which falsely assumes the union's
LANG_SPECIFIC array is sorted, and may loop indefinitely because of
this.

2018-08-03  Bogdan Harjoc  <harjoc@gmail.com>

PR c/86690
gcc/c:
* c-typeck.c (lookup_field): Do not use TYPE_LANG_SPECIFIC after
errors.

gcc/testsuite:
* gcc.dg/union-duplicate-field.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263294 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/union-duplicate-field.c [new file with mode: 0644]