Patchwork [RFC] bail out after front-end errors

login
register
mail settings
Submitter Steven Bosscher
Date March 26, 2012, 8:56 p.m.
Message ID <CABu31nO=g3DzWR0Rce8CgVsWwu6bDvhNBBbYWyYdLMnn7-a7rQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/148834/
State New
Headers show

Comments

Steven Bosscher - March 26, 2012, 8:56 p.m.
Hello,

This patch is one way to address PR44982. I see no good reason to
cgraph_finalize_compilation_unit if there were parse errors. As Richi
already pointed out, GCC traditionally has proceeded after parse
errors to preserve warnings and errors we generate from the middle-end
and during semantic analysis. But it seems to me that those warnings
are not very meaningful after parse errors (-Wuninitialized after a
parse error??), and errors from the middle end are mostly for exotic
code (involving asm()s and the like). Bailing out after parse errors
is therefore IMHO the right thing to do for the common case.

Thoughts? Comments?

If the consensus is that this patch goes in, I'll also have to do some
work on the test suite, because some warnings and errors disappear.
List attached below. A lot of errors and warnings from g++ disappear.
I suspect this is because they are only issued during gimplification.
That is something I'll have to address before this patch could go in.
Before I spend the effort, I'd like to know if there is consensus on
the general direction proposed here... ;-)

Ciao!
Steven





New failing tests:
> FAIL: gcc.dg/asm-7.c  (test for errors, line 15)
> FAIL: gcc.dg/asm-7.c  (test for errors, line 16)
> FAIL: gcc.dg/declspec-10.c  (test for warnings, line 19)
> FAIL: gcc.dg/declspec-11.c  (test for warnings, line 19)
> FAIL: gcc.dg/declspec-9.c  (test for errors, line 20)
> FAIL: gcc.dg/gnu99-static-1.c  (test for errors, line 21)
> FAIL: gcc.dg/gnu99-static-1.c  (test for errors, line 25)
> FAIL: gcc.dg/pr48552-1.c  (test for errors, line 16)
> FAIL: gcc.dg/pr48552-1.c  (test for errors, line 40)
> FAIL: gcc.dg/pr48552-1.c  (test for errors, line 52)
> FAIL: gcc.dg/pr48552-2.c  (test for errors, line 16)
> FAIL: gcc.dg/pr48552-2.c  (test for errors, line 40)
> FAIL: gcc.dg/pr48552-2.c  (test for errors, line 52)
> FAIL: gcc.dg/redecl-10.c  (test for warnings, line 15)
> FAIL: gcc.dg/redecl-10.c  (test for warnings, line 29)
> FAIL: gcc.dg/gomp/block-2.c  (test for errors, line 14)
> FAIL: gcc.dg/gomp/block-2.c  (test for errors, line 16)
> FAIL: gcc.dg/gomp/block-7.c  (test for errors, line 9)
> FAIL: gcc.dg/gomp/block-7.c  (test for errors, line 10)
> FAIL: gcc.dg/gomp/block-7.c  (test for errors, line 11)
> FAIL: gcc.dg/gomp/block-7.c  (test for errors, line 15)
> FAIL: gcc.dg/gomp/block-7.c  (test for errors, line 16)
> FAIL: gcc.dg/gomp/block-7.c  (test for errors, line 17)
> FAIL: gcc.dg/gomp/pr27415.c  (test for errors, line 9)
> FAIL: gcc.dg/gomp/pr27415.c  (test for errors, line 28)
> FAIL: gcc.dg/gomp/pr27415.c  (test for errors, line 37)
> FAIL: c-c++-common/tm/safe-3.c (internal compiler error)
> FAIL: c-c++-common/tm/safe-3.c (test for excess errors)
> FAIL: gcc.dg/tm/pr52141.c (internal compiler error)
> FAIL: gcc.dg/tm/pr52141.c (test for excess errors)
> FAIL: g++.dg/cpp0x/constexpr-ex1.C  (test for warnings, line 17)
> FAIL: g++.dg/cpp0x/constexpr-function2.C  (test for warnings, line 46)
> FAIL: g++.dg/cpp0x/constexpr-neg1.C  (test for warnings, line 5)
> FAIL: g++.dg/cpp0x/lambda/lambda-ctor-neg.C  (test for warnings, line 15)
> FAIL: g++.dg/cpp0x/lambda/lambda-ctor-neg.C not an aggregate (test for errors, line 16)
> FAIL: g++.dg/cpp0x/lambda/lambda-ctor-neg.C deleted default ctor (test for errors, line 17)
> FAIL: g++.dg/cpp0x/lambda/lambda-ctor-neg.C deleted assignment op (test for errors, line 18)
> FAIL: g++.dg/cpp0x/lambda/lambda-field-names.C no member named i (test for errors, line 11)
> FAIL: g++.dg/cpp0x/noexcept15.C  (test for errors, line 16)
> FAIL: g++.dg/cpp0x/pr47416.C  (test for errors, line 187)
> FAIL: g++.dg/cpp0x/pr47416.C  (test for warnings, line 213)
> FAIL: g++.dg/cpp0x/pr47416.C  (test for warnings, line 223)
> FAIL: g++.dg/cpp0x/static_assert2.C  (test for errors, line 14)
> FAIL: g++.dg/cpp0x/union1.C  (test for errors, line 17)
> FAIL: g++.dg/cpp0x/union1.C  (test for errors, line 18)
> FAIL: g++.dg/cpp0x/union1.C  (test for errors, line 28)
> FAIL: g++.dg/cpp0x/union1.C  (test for errors, line 29)
> FAIL: g++.dg/cpp0x/vt-37737-2.C  (test for warnings, line 4)
> FAIL: g++.dg/cpp0x/vt-37737-2.C  (test for errors, line 6)
> FAIL: g++.dg/cpp0x/vt-37737-2.C candidate note (test for warnings, line 6)
> FAIL: g++.dg/ext/case-range2.C -std=gnu++98  (test for errors, line 14)
> FAIL: g++.dg/ext/case-range2.C -std=gnu++98  (test for errors, line 15)
> FAIL: g++.dg/ext/case-range2.C -std=gnu++98  (test for warnings, line 25)
> FAIL: g++.dg/ext/case-range2.C -std=gnu++11  (test for errors, line 14)
> FAIL: g++.dg/ext/case-range2.C -std=gnu++11  (test for errors, line 15)
> FAIL: g++.dg/ext/case-range2.C -std=gnu++11  (test for warnings, line 25)
> FAIL: g++.dg/init/pr42844.C -std=c++98  (test for warnings, line 44)
> FAIL: g++.dg/init/pr42844.C -std=c++98  (test for warnings, line 46)
> FAIL: g++.dg/init/pr42844.C -std=c++98  (test for errors, line 51)
> FAIL: g++.dg/init/pr42844.C -std=c++11  (test for warnings, line 44)
> FAIL: g++.dg/init/pr42844.C -std=c++11  (test for warnings, line 46)
> FAIL: g++.dg/init/pr42844.C -std=c++11  (test for errors, line 51)
> FAIL: g++.dg/parse/template18.C -std=c++98  (test for errors, line 47)
> FAIL: g++.dg/parse/template18.C -std=c++98  (test for warnings, line 52)
> FAIL: g++.dg/parse/template18.C -std=c++11  (test for errors, line 47)
> FAIL: g++.dg/parse/template18.C -std=c++11  (test for warnings, line 52)
> FAIL: g++.dg/parse/typename7.C -std=c++98  (test for warnings, line 10)
> FAIL: g++.dg/parse/typename7.C -std=c++98  (test for warnings, line 11)
> FAIL: g++.dg/parse/typename7.C -std=c++98 candidate note (test for warnings, line 12)
> FAIL: g++.dg/parse/typename7.C -std=c++98 candidate note (test for warnings, line 22)
> FAIL: g++.dg/parse/typename7.C -std=c++11  (test for warnings, line 10)
> FAIL: g++.dg/parse/typename7.C -std=c++11  (test for warnings, line 11)
> FAIL: g++.dg/parse/typename7.C -std=c++11 candidate note (test for warnings, line 12)
> FAIL: g++.dg/parse/typename7.C -std=c++11 candidate note (test for warnings, line 22)
> FAIL: g++.dg/tc1/dr152.C -std=c++98  (test for warnings, line 22)
> FAIL: g++.dg/tc1/dr152.C -std=c++98  (test for errors, line 27)
> FAIL: g++.dg/tc1/dr152.C -std=c++98 matching (test for errors, line 33)
> FAIL: g++.dg/tc1/dr152.C -std=c++98 candidate note (test for warnings, line 33)
> FAIL: g++.dg/tc1/dr152.C -std=c++98  (test for warnings, line 37)
> FAIL: g++.dg/tc1/dr152.C -std=c++11  (test for warnings, line 22)
> FAIL: g++.dg/tc1/dr152.C -std=c++11  (test for errors, line 27)
> FAIL: g++.dg/tc1/dr152.C -std=c++11 matching (test for errors, line 33)
> FAIL: g++.dg/tc1/dr152.C -std=c++11 candidate note (test for warnings, line 33)
> FAIL: g++.dg/tc1/dr152.C -std=c++11  (test for warnings, line 37)
> FAIL: g++.dg/tc1/dr166.C -std=c++98  (test for errors, line 27)
> FAIL: g++.dg/tc1/dr166.C -std=c++98  (test for warnings, line 35)
> FAIL: g++.dg/tc1/dr166.C -std=c++98  (test for errors, line 44)
> FAIL: g++.dg/tc1/dr166.C -std=c++98  (test for errors, line 45)
> FAIL: g++.dg/tc1/dr166.C -std=c++11  (test for warnings, line 50)
> FAIL: g++.dg/template/access2.C -std=c++98  (test for errors, line 8)
> FAIL: g++.dg/template/access2.C -std=c++98  (test for errors, line 13)
> FAIL: g++.dg/template/access2.C -std=c++98  (test for warnings, line 19)
> FAIL: g++.dg/template/access2.C -std=c++11  (test for errors, line 8)
> FAIL: g++.dg/template/access2.C -std=c++11  (test for errors, line 13)
> FAIL: g++.dg/template/access2.C -std=c++11  (test for warnings, line 19)
> FAIL: g++.dg/template/crash107.C -std=gnu++98  (test for warnings, line 13)
> FAIL: g++.dg/template/crash107.C -std=gnu++98  (test for warnings, line 20)
> FAIL: g++.dg/template/crash107.C -std=gnu++11  (test for warnings, line 13)
> FAIL: g++.dg/template/crash107.C -std=gnu++11  (test for warnings, line 20)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++98  (test for errors, line 86)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++98  (test for errors, line 110)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++98 candidate note (test for warnings, line 110)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++98  (test for errors, line 112)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++98 candidate note (test for warnings, line 112)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++98  (test for errors, line 115)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++98 candidate note (test for warnings, line 115)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++98  (test for errors, line 123)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++98 candidate note (test for warnings, line 123)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++11  (test for errors, line 110)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++11 candidate note (test for warnings, line 110)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++11  (test for errors, line 112)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++11 candidate note (test for warnings, line 112)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++11  (test for errors, line 115)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++11 candidate note (test for warnings, line 115)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++11  (test for errors, line 123)
> FAIL: g++.dg/template/dependent-expr5.C -std=c++11 candidate note (test for warnings, line 123)
> FAIL: g++.dg/template/error15.C -std=c++98  (test for errors, line 21)
> FAIL: g++.dg/template/error15.C -std=c++11  (test for errors, line 21)
> FAIL: g++.dg/template/error43.C -std=c++98  (test for warnings, line 9)
> FAIL: g++.dg/template/error43.C -std=c++11  (test for warnings, line 9)
> FAIL: g++.dg/template/friend31.C -std=c++98  (test for errors, line 13)
> FAIL: g++.dg/template/friend31.C -std=c++98  (test for errors, line 18)
> FAIL: g++.dg/template/friend31.C -std=c++11  (test for errors, line 13)
> FAIL: g++.dg/template/friend31.C -std=c++11  (test for errors, line 18)
> FAIL: g++.dg/template/instantiate3.C -std=c++98  (test for errors, line 13)
> FAIL: g++.dg/template/instantiate3.C -std=c++11  (test for errors, line 13)
> FAIL: g++.dg/template/memfriend7.C -std=c++98  (test for errors, line 39)
> FAIL: g++.dg/template/memfriend7.C -std=c++98  (test for errors, line 45)
> FAIL: g++.dg/template/memfriend7.C -std=c++98  (test for errors, line 51)
> FAIL: g++.dg/template/memfriend7.C -std=c++98  (test for errors, line 57)
> FAIL: g++.dg/template/memfriend7.C -std=c++98  (test for errors, line 63)
> FAIL: g++.dg/template/memfriend7.C -std=c++98  (test for errors, line 83)
> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for errors, line 107)
> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 119)
> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 120)
> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 121)
> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 122)
> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 123)
> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 124)
> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 127)
> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 131)
> FAIL: g++.dg/template/nontype12.C -std=c++98  (test for errors, line 27)
> FAIL: g++.dg/template/nontype12.C -std=c++98  (test for warnings, line 30)
> FAIL: g++.dg/template/nontype12.C -std=c++98  (test for warnings, line 34)
> FAIL: g++.dg/template/nontype12.C -std=c++11  (test for errors, line 27)
> FAIL: g++.dg/template/nontype12.C -std=c++11  (test for warnings, line 30)
> FAIL: g++.dg/template/nontype12.C -std=c++11  (test for warnings, line 34)
> FAIL: g++.dg/template/pseudodtor3.C -std=c++98  (test for errors, line 14)
> FAIL: g++.dg/template/pseudodtor3.C -std=c++98  (test for errors, line 22)
> FAIL: g++.dg/template/pseudodtor3.C -std=c++98  (test for errors, line 31)
> FAIL: g++.dg/template/pseudodtor3.C -std=c++98  (test for errors, line 40)
> FAIL: g++.dg/template/pseudodtor3.C -std=c++11  (test for errors, line 14)
> FAIL: g++.dg/template/pseudodtor3.C -std=c++11  (test for errors, line 22)
> FAIL: g++.dg/template/pseudodtor3.C -std=c++11  (test for errors, line 31)
> FAIL: g++.dg/template/pseudodtor3.C -std=c++11  (test for errors, line 40)
> FAIL: g++.dg/template/using16.C -std=c++98  (test for errors, line 14)
> FAIL: g++.dg/template/using16.C -std=c++98  (test for errors, line 25)
> FAIL: g++.dg/template/using16.C -std=c++98  (test for warnings, line 29)
> FAIL: g++.dg/template/using16.C -std=c++11  (test for errors, line 14)
> FAIL: g++.dg/template/using16.C -std=c++11  (test for errors, line 25)
> FAIL: g++.dg/template/using16.C -std=c++11  (test for warnings, line 29)
> FAIL: g++.dg/template/virtual3.C -std=c++98  (test for errors, line 8)
> FAIL: g++.dg/gomp/block-1.C -std=c++98  (test for warnings, line 7)
> FAIL: g++.dg/gomp/block-1.C -std=c++98  (test for warnings, line 9)
> FAIL: g++.dg/gomp/block-1.C -std=c++11  (test for warnings, line 7)
> FAIL: g++.dg/gomp/block-1.C -std=c++11  (test for warnings, line 9)
> FAIL: g++.dg/gomp/block-2.C -std=c++98  (test for warnings, line 14)
> FAIL: g++.dg/gomp/block-2.C -std=c++98  (test for warnings, line 16)
> FAIL: g++.dg/gomp/block-2.C -std=c++11  (test for warnings, line 14)
> FAIL: g++.dg/gomp/block-2.C -std=c++11  (test for warnings, line 16)
> FAIL: g++.dg/gomp/block-3.C -std=c++98  (test for warnings, line 21)
> FAIL: g++.dg/gomp/block-3.C -std=c++98  (test for warnings, line 26)
> FAIL: g++.dg/gomp/block-3.C -std=c++98  (test for warnings, line 30)
> FAIL: g++.dg/gomp/block-3.C -std=c++11  (test for warnings, line 21)
> FAIL: g++.dg/gomp/block-3.C -std=c++11  (test for warnings, line 26)
> FAIL: g++.dg/gomp/block-3.C -std=c++11  (test for warnings, line 30)
> FAIL: g++.dg/gomp/block-5.C -std=c++98  (test for warnings, line 7)
> FAIL: g++.dg/gomp/block-5.C -std=c++11  (test for warnings, line 7)
> FAIL: g++.dg/gomp/for-19.C -std=gnu++98  (test for errors, line 11)
> FAIL: g++.dg/gomp/for-19.C -std=gnu++98  (test for errors, line 29)
> FAIL: g++.dg/gomp/for-19.C -std=gnu++98  (test for warnings, line 37)
> FAIL: g++.dg/gomp/for-19.C -std=gnu++98  (test for warnings, line 40)
> FAIL: g++.dg/gomp/for-19.C -std=gnu++11  (test for errors, line 11)
> FAIL: g++.dg/gomp/for-19.C -std=gnu++11  (test for errors, line 29)
> FAIL: g++.dg/gomp/for-19.C -std=gnu++11  (test for warnings, line 37)
> FAIL: g++.dg/gomp/for-19.C -std=gnu++11  (test for warnings, line 40)
> FAIL: g++.dg/gomp/pr27415.C -std=c++98  (test for errors, line 9)
> FAIL: g++.dg/gomp/pr27415.C -std=c++98  (test for errors, line 28)
> FAIL: g++.dg/gomp/pr27415.C -std=c++98  (test for errors, line 38)
> FAIL: g++.dg/gomp/pr27415.C -std=c++11  (test for errors, line 9)
> FAIL: g++.dg/gomp/pr27415.C -std=c++11  (test for errors, line 28)
> FAIL: g++.dg/gomp/pr27415.C -std=c++11  (test for errors, line 38)
> FAIL: c-c++-common/tm/safe-3.c -std=gnu++98 (internal compiler error)
> FAIL: c-c++-common/tm/safe-3.c -std=gnu++98 (test for excess errors)
> FAIL: c-c++-common/tm/safe-3.c -std=gnu++11 (internal compiler error)
> FAIL: c-c++-common/tm/safe-3.c -std=gnu++11 (test for excess errors)
> FAIL: g++.dg/tm/noexcept-2.C  (test for errors, line 7)
> FAIL: g++.dg/tm/noexcept-2.C  (test for errors, line 8)
> FAIL: g++.old-deja/g++.eh/spec6.C -std=c++98  (test for errors, line 24)
> FAIL: g++.old-deja/g++.eh/spec6.C -std=c++98  (test for warnings, line 28)
> FAIL: g++.old-deja/g++.eh/spec6.C -std=c++11  (test for errors, line 24)
> FAIL: g++.old-deja/g++.eh/spec6.C -std=c++11  (test for warnings, line 28)
> FAIL: g++.old-deja/g++.jason/report.C -std=gnu++98  (test for warnings, line 36)
> FAIL: g++.old-deja/g++.jason/report.C -std=gnu++98  (test for warnings, line 65)
> FAIL: g++.old-deja/g++.jason/report.C -std=gnu++11  (test for warnings, line 36)
> FAIL: g++.old-deja/g++.jason/report.C -std=gnu++11  (test for warnings, line 65)
> FAIL: g++.old-deja/g++.mike/net31.C -std=c++98  (test for errors, line 43)
> FAIL: g++.old-deja/g++.mike/net31.C -std=c++11  (test for errors, line 43)
> FAIL: g++.old-deja/g++.niklas/t135.C -std=c++98  (test for errors, line 11)
> FAIL: g++.old-deja/g++.niklas/t135.C -std=c++98  (test for errors, line 19)
> FAIL: g++.old-deja/g++.niklas/t135.C -std=c++11  (test for errors, line 11)
> FAIL: g++.old-deja/g++.niklas/t135.C -std=c++11  (test for errors, line 19)
> FAIL: g++.old-deja/g++.oliva/delete1.C -std=c++98  (test for warnings, line 31)
> FAIL: g++.old-deja/g++.other/friend1.C -std=c++98  (test for errors, line 63)
> FAIL: g++.old-deja/g++.other/friend1.C -std=c++98  (test for errors, line 82)
> FAIL: g++.old-deja/g++.other/friend1.C -std=c++11  (test for errors, line 63)
> FAIL: g++.old-deja/g++.other/friend1.C -std=c++11  (test for errors, line 82)
> FAIL: g++.old-deja/g++.other/friend4.C -std=c++98  (test for errors, line 13)
> FAIL: g++.old-deja/g++.other/friend4.C -std=c++98  (test for errors, line 17)
> FAIL: g++.old-deja/g++.other/friend4.C -std=c++98  (test for errors, line 18)
> FAIL: g++.old-deja/g++.other/friend4.C -std=c++11  (test for errors, line 13)
> FAIL: g++.old-deja/g++.other/friend4.C -std=c++11  (test for errors, line 17)
> FAIL: g++.old-deja/g++.other/friend4.C -std=c++11  (test for errors, line 18)
> FAIL: g++.old-deja/g++.other/lineno1.C -std=gnu++98  (test for errors, line 9)
> FAIL: g++.old-deja/g++.other/lineno1.C -std=gnu++11  (test for errors, line 9)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98  (test for warnings, line 24)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 pass (test for warnings, line 24)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 abort (test for warnings, line 24)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98  (test for warnings, line 28)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 abort (test for warnings, line 28)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 promote (test for warnings, line 30)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 abort (test for warnings, line 30)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11  (test for warnings, line 24)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 pass (test for warnings, line 24)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 abort (test for warnings, line 24)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11  (test for warnings, line 28)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 abort (test for warnings, line 28)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 promote (test for warnings, line 30)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 abort (test for warnings, line 30)
> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++98  (test for errors, line 6)
> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++98  (test for warnings, line 16)
> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++11  (test for errors, line 6)
> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++11  (test for warnings, line 16)
> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++98 no def (test for errors, line 43)
> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++98 inst (test for warnings, line 43)
> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++11 no def (test for errors, line 43)
> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++11 inst (test for warnings, line 43)
> FAIL: g++.old-deja/g++.pt/instantiate8.C -std=c++98  (test for errors, line 36)
> FAIL: g++.old-deja/g++.pt/instantiate8.C -std=c++11  (test for errors, line 36)
> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++98  (test for errors, line 17)
> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++98 inst (test for warnings, line 24)
> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++11  (test for errors, line 17)
> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++11 inst (test for warnings, line 24)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 45)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 47)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 51)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 52)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 56)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 45)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 47)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 51)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 52)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 56)
> FAIL: objc.dg/property/dotsyntax-17.m -fgnu-runtime  (test for errors, line 56)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98  (test for warnings, line 24)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 pass (test for warnings, line 24)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 abort (test for warnings, line 24)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98  (test for warnings, line 28)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 abort (test for warnings, line 28)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 promote (test for warnings, line 30)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 abort (test for warnings, line 30)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11  (test for warnings, line 24)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 pass (test for warnings, line 24)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 abort (test for warnings, line 24)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11  (test for warnings, line 28)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 abort (test for warnings, line 28)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 promote (test for warnings, line 30)
> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 abort (test for warnings, line 30)
> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++98  (test for errors, line 6)
> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++98  (test for warnings, line 16)
> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++11  (test for errors, line 6)
> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++11  (test for warnings, line 16)
> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++98 no def (test for errors, line 43)
> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++98 inst (test for warnings, line 43)
> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++11 no def (test for errors, line 43)
> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++11 inst (test for warnings, line 43)
> FAIL: g++.old-deja/g++.pt/instantiate8.C -std=c++98  (test for errors, line 36)
> FAIL: g++.old-deja/g++.pt/instantiate8.C -std=c++11  (test for errors, line 36)
> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++98  (test for errors, line 17)
> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++98 inst (test for warnings, line 24)
> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++11  (test for errors, line 17)
> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++11 inst (test for warnings, line 24)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 45)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 47)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 51)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 52)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 56)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 45)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 47)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 51)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 52)
> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 56)
> FAIL: objc.dg/property/dotsyntax-17.m -fgnu-runtime  (test for errors, line 56)
> FAIL: objc.dg/property/dotsyntax-17.m -fgnu-runtime  (test for errors, line 58)
> FAIL: objc.dg/property/dotsyntax-17.m -fgnu-runtime  (test for errors, line 60)
> FAIL: objc.dg/property/dotsyntax-17.m -fgnu-runtime  (test for errors, line 62)
> FAIL: 20_util/unique_ptr/cons/ptr_deleter_neg.cc  (test for errors, line 37)
> FAIL: 20_util/unique_ptr/cons/ptr_deleter_neg.cc  (test for errors, line 47)
Richard Guenther - March 27, 2012, 7:17 a.m.
On Mon, Mar 26, 2012 at 10:56 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> Hello,
>
> This patch is one way to address PR44982. I see no good reason to
> cgraph_finalize_compilation_unit if there were parse errors. As Richi
> already pointed out, GCC traditionally has proceeded after parse
> errors to preserve warnings and errors we generate from the middle-end
> and during semantic analysis. But it seems to me that those warnings
> are not very meaningful after parse errors (-Wuninitialized after a
> parse error??), and errors from the middle end are mostly for exotic
> code (involving asm()s and the like). Bailing out after parse errors
> is therefore IMHO the right thing to do for the common case.
>
> Thoughts? Comments?

Conceptually it makes sense.  Did you check whether allowing the
FE too proceed to final_write_globals but stop before
cgraph_finalize_compilation_unit
preserves any errors?  I would expect that maybe FE global variable
diagostics are defered until that?  It would be nice to finally move
the call to cgraph_finalize_compilation_unit to the middle-end ...
(warning, if you try that you run into an issue with the Java frontend ... :/)

Richard.

> If the consensus is that this patch goes in, I'll also have to do some
> work on the test suite, because some warnings and errors disappear.
> List attached below. A lot of errors and warnings from g++ disappear.
> I suspect this is because they are only issued during gimplification.
> That is something I'll have to address before this patch could go in.
> Before I spend the effort, I'd like to know if there is consensus on
> the general direction proposed here... ;-)
>
> Ciao!
> Steven
>
>
>
> Index: toplev.c
> ===================================================================
> --- toplev.c    (revision 185813)
> +++ toplev.c    (working copy)
> @@ -561,9 +561,14 @@ compile_file (void)
>   /* Compilation is now finished except for writing
>      what's left of the symbol table output.  */
>
> -  if (flag_syntax_only || flag_wpa)
> +  /* If all we have to do is syntax checking, or if there were parse
> +     errors, stop here.  */
> +  if (flag_syntax_only || seen_error ())
>     return;
>
> +  if (flag_wpa)
> +    return;
> +
>   timevar_start (TV_PHASE_GENERATE);
>
>   ggc_protect_identifiers = false;
> @@ -571,12 +576,6 @@ compile_file (void)
>   /* This must also call cgraph_finalize_compilation_unit.  */
>   lang_hooks.decls.final_write_globals ();
>
> -  if (seen_error ())
> -    {
> -      timevar_stop (TV_PHASE_GENERATE);
> -      return;
> -    }
> -
>   /* Compilation unit is finalized.  When producing non-fat LTO object, we are
>      basically finished.  */
>   if (in_lto_p || !flag_lto || flag_fat_lto_objects)
>
>
> New failing tests:
>> FAIL: gcc.dg/asm-7.c  (test for errors, line 15)
>> FAIL: gcc.dg/asm-7.c  (test for errors, line 16)
>> FAIL: gcc.dg/declspec-10.c  (test for warnings, line 19)
>> FAIL: gcc.dg/declspec-11.c  (test for warnings, line 19)
>> FAIL: gcc.dg/declspec-9.c  (test for errors, line 20)
>> FAIL: gcc.dg/gnu99-static-1.c  (test for errors, line 21)
>> FAIL: gcc.dg/gnu99-static-1.c  (test for errors, line 25)
>> FAIL: gcc.dg/pr48552-1.c  (test for errors, line 16)
>> FAIL: gcc.dg/pr48552-1.c  (test for errors, line 40)
>> FAIL: gcc.dg/pr48552-1.c  (test for errors, line 52)
>> FAIL: gcc.dg/pr48552-2.c  (test for errors, line 16)
>> FAIL: gcc.dg/pr48552-2.c  (test for errors, line 40)
>> FAIL: gcc.dg/pr48552-2.c  (test for errors, line 52)
>> FAIL: gcc.dg/redecl-10.c  (test for warnings, line 15)
>> FAIL: gcc.dg/redecl-10.c  (test for warnings, line 29)
>> FAIL: gcc.dg/gomp/block-2.c  (test for errors, line 14)
>> FAIL: gcc.dg/gomp/block-2.c  (test for errors, line 16)
>> FAIL: gcc.dg/gomp/block-7.c  (test for errors, line 9)
>> FAIL: gcc.dg/gomp/block-7.c  (test for errors, line 10)
>> FAIL: gcc.dg/gomp/block-7.c  (test for errors, line 11)
>> FAIL: gcc.dg/gomp/block-7.c  (test for errors, line 15)
>> FAIL: gcc.dg/gomp/block-7.c  (test for errors, line 16)
>> FAIL: gcc.dg/gomp/block-7.c  (test for errors, line 17)
>> FAIL: gcc.dg/gomp/pr27415.c  (test for errors, line 9)
>> FAIL: gcc.dg/gomp/pr27415.c  (test for errors, line 28)
>> FAIL: gcc.dg/gomp/pr27415.c  (test for errors, line 37)
>> FAIL: c-c++-common/tm/safe-3.c (internal compiler error)
>> FAIL: c-c++-common/tm/safe-3.c (test for excess errors)
>> FAIL: gcc.dg/tm/pr52141.c (internal compiler error)
>> FAIL: gcc.dg/tm/pr52141.c (test for excess errors)
>> FAIL: g++.dg/cpp0x/constexpr-ex1.C  (test for warnings, line 17)
>> FAIL: g++.dg/cpp0x/constexpr-function2.C  (test for warnings, line 46)
>> FAIL: g++.dg/cpp0x/constexpr-neg1.C  (test for warnings, line 5)
>> FAIL: g++.dg/cpp0x/lambda/lambda-ctor-neg.C  (test for warnings, line 15)
>> FAIL: g++.dg/cpp0x/lambda/lambda-ctor-neg.C not an aggregate (test for errors, line 16)
>> FAIL: g++.dg/cpp0x/lambda/lambda-ctor-neg.C deleted default ctor (test for errors, line 17)
>> FAIL: g++.dg/cpp0x/lambda/lambda-ctor-neg.C deleted assignment op (test for errors, line 18)
>> FAIL: g++.dg/cpp0x/lambda/lambda-field-names.C no member named i (test for errors, line 11)
>> FAIL: g++.dg/cpp0x/noexcept15.C  (test for errors, line 16)
>> FAIL: g++.dg/cpp0x/pr47416.C  (test for errors, line 187)
>> FAIL: g++.dg/cpp0x/pr47416.C  (test for warnings, line 213)
>> FAIL: g++.dg/cpp0x/pr47416.C  (test for warnings, line 223)
>> FAIL: g++.dg/cpp0x/static_assert2.C  (test for errors, line 14)
>> FAIL: g++.dg/cpp0x/union1.C  (test for errors, line 17)
>> FAIL: g++.dg/cpp0x/union1.C  (test for errors, line 18)
>> FAIL: g++.dg/cpp0x/union1.C  (test for errors, line 28)
>> FAIL: g++.dg/cpp0x/union1.C  (test for errors, line 29)
>> FAIL: g++.dg/cpp0x/vt-37737-2.C  (test for warnings, line 4)
>> FAIL: g++.dg/cpp0x/vt-37737-2.C  (test for errors, line 6)
>> FAIL: g++.dg/cpp0x/vt-37737-2.C candidate note (test for warnings, line 6)
>> FAIL: g++.dg/ext/case-range2.C -std=gnu++98  (test for errors, line 14)
>> FAIL: g++.dg/ext/case-range2.C -std=gnu++98  (test for errors, line 15)
>> FAIL: g++.dg/ext/case-range2.C -std=gnu++98  (test for warnings, line 25)
>> FAIL: g++.dg/ext/case-range2.C -std=gnu++11  (test for errors, line 14)
>> FAIL: g++.dg/ext/case-range2.C -std=gnu++11  (test for errors, line 15)
>> FAIL: g++.dg/ext/case-range2.C -std=gnu++11  (test for warnings, line 25)
>> FAIL: g++.dg/init/pr42844.C -std=c++98  (test for warnings, line 44)
>> FAIL: g++.dg/init/pr42844.C -std=c++98  (test for warnings, line 46)
>> FAIL: g++.dg/init/pr42844.C -std=c++98  (test for errors, line 51)
>> FAIL: g++.dg/init/pr42844.C -std=c++11  (test for warnings, line 44)
>> FAIL: g++.dg/init/pr42844.C -std=c++11  (test for warnings, line 46)
>> FAIL: g++.dg/init/pr42844.C -std=c++11  (test for errors, line 51)
>> FAIL: g++.dg/parse/template18.C -std=c++98  (test for errors, line 47)
>> FAIL: g++.dg/parse/template18.C -std=c++98  (test for warnings, line 52)
>> FAIL: g++.dg/parse/template18.C -std=c++11  (test for errors, line 47)
>> FAIL: g++.dg/parse/template18.C -std=c++11  (test for warnings, line 52)
>> FAIL: g++.dg/parse/typename7.C -std=c++98  (test for warnings, line 10)
>> FAIL: g++.dg/parse/typename7.C -std=c++98  (test for warnings, line 11)
>> FAIL: g++.dg/parse/typename7.C -std=c++98 candidate note (test for warnings, line 12)
>> FAIL: g++.dg/parse/typename7.C -std=c++98 candidate note (test for warnings, line 22)
>> FAIL: g++.dg/parse/typename7.C -std=c++11  (test for warnings, line 10)
>> FAIL: g++.dg/parse/typename7.C -std=c++11  (test for warnings, line 11)
>> FAIL: g++.dg/parse/typename7.C -std=c++11 candidate note (test for warnings, line 12)
>> FAIL: g++.dg/parse/typename7.C -std=c++11 candidate note (test for warnings, line 22)
>> FAIL: g++.dg/tc1/dr152.C -std=c++98  (test for warnings, line 22)
>> FAIL: g++.dg/tc1/dr152.C -std=c++98  (test for errors, line 27)
>> FAIL: g++.dg/tc1/dr152.C -std=c++98 matching (test for errors, line 33)
>> FAIL: g++.dg/tc1/dr152.C -std=c++98 candidate note (test for warnings, line 33)
>> FAIL: g++.dg/tc1/dr152.C -std=c++98  (test for warnings, line 37)
>> FAIL: g++.dg/tc1/dr152.C -std=c++11  (test for warnings, line 22)
>> FAIL: g++.dg/tc1/dr152.C -std=c++11  (test for errors, line 27)
>> FAIL: g++.dg/tc1/dr152.C -std=c++11 matching (test for errors, line 33)
>> FAIL: g++.dg/tc1/dr152.C -std=c++11 candidate note (test for warnings, line 33)
>> FAIL: g++.dg/tc1/dr152.C -std=c++11  (test for warnings, line 37)
>> FAIL: g++.dg/tc1/dr166.C -std=c++98  (test for errors, line 27)
>> FAIL: g++.dg/tc1/dr166.C -std=c++98  (test for warnings, line 35)
>> FAIL: g++.dg/tc1/dr166.C -std=c++98  (test for errors, line 44)
>> FAIL: g++.dg/tc1/dr166.C -std=c++98  (test for errors, line 45)
>> FAIL: g++.dg/tc1/dr166.C -std=c++11  (test for warnings, line 50)
>> FAIL: g++.dg/template/access2.C -std=c++98  (test for errors, line 8)
>> FAIL: g++.dg/template/access2.C -std=c++98  (test for errors, line 13)
>> FAIL: g++.dg/template/access2.C -std=c++98  (test for warnings, line 19)
>> FAIL: g++.dg/template/access2.C -std=c++11  (test for errors, line 8)
>> FAIL: g++.dg/template/access2.C -std=c++11  (test for errors, line 13)
>> FAIL: g++.dg/template/access2.C -std=c++11  (test for warnings, line 19)
>> FAIL: g++.dg/template/crash107.C -std=gnu++98  (test for warnings, line 13)
>> FAIL: g++.dg/template/crash107.C -std=gnu++98  (test for warnings, line 20)
>> FAIL: g++.dg/template/crash107.C -std=gnu++11  (test for warnings, line 13)
>> FAIL: g++.dg/template/crash107.C -std=gnu++11  (test for warnings, line 20)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++98  (test for errors, line 86)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++98  (test for errors, line 110)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++98 candidate note (test for warnings, line 110)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++98  (test for errors, line 112)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++98 candidate note (test for warnings, line 112)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++98  (test for errors, line 115)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++98 candidate note (test for warnings, line 115)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++98  (test for errors, line 123)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++98 candidate note (test for warnings, line 123)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++11  (test for errors, line 110)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++11 candidate note (test for warnings, line 110)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++11  (test for errors, line 112)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++11 candidate note (test for warnings, line 112)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++11  (test for errors, line 115)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++11 candidate note (test for warnings, line 115)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++11  (test for errors, line 123)
>> FAIL: g++.dg/template/dependent-expr5.C -std=c++11 candidate note (test for warnings, line 123)
>> FAIL: g++.dg/template/error15.C -std=c++98  (test for errors, line 21)
>> FAIL: g++.dg/template/error15.C -std=c++11  (test for errors, line 21)
>> FAIL: g++.dg/template/error43.C -std=c++98  (test for warnings, line 9)
>> FAIL: g++.dg/template/error43.C -std=c++11  (test for warnings, line 9)
>> FAIL: g++.dg/template/friend31.C -std=c++98  (test for errors, line 13)
>> FAIL: g++.dg/template/friend31.C -std=c++98  (test for errors, line 18)
>> FAIL: g++.dg/template/friend31.C -std=c++11  (test for errors, line 13)
>> FAIL: g++.dg/template/friend31.C -std=c++11  (test for errors, line 18)
>> FAIL: g++.dg/template/instantiate3.C -std=c++98  (test for errors, line 13)
>> FAIL: g++.dg/template/instantiate3.C -std=c++11  (test for errors, line 13)
>> FAIL: g++.dg/template/memfriend7.C -std=c++98  (test for errors, line 39)
>> FAIL: g++.dg/template/memfriend7.C -std=c++98  (test for errors, line 45)
>> FAIL: g++.dg/template/memfriend7.C -std=c++98  (test for errors, line 51)
>> FAIL: g++.dg/template/memfriend7.C -std=c++98  (test for errors, line 57)
>> FAIL: g++.dg/template/memfriend7.C -std=c++98  (test for errors, line 63)
>> FAIL: g++.dg/template/memfriend7.C -std=c++98  (test for errors, line 83)
>> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for errors, line 107)
>> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 119)
>> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 120)
>> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 121)
>> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 122)
>> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 123)
>> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 124)
>> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 127)
>> FAIL: g++.dg/template/memfriend7.C -std=c++11  (test for warnings, line 131)
>> FAIL: g++.dg/template/nontype12.C -std=c++98  (test for errors, line 27)
>> FAIL: g++.dg/template/nontype12.C -std=c++98  (test for warnings, line 30)
>> FAIL: g++.dg/template/nontype12.C -std=c++98  (test for warnings, line 34)
>> FAIL: g++.dg/template/nontype12.C -std=c++11  (test for errors, line 27)
>> FAIL: g++.dg/template/nontype12.C -std=c++11  (test for warnings, line 30)
>> FAIL: g++.dg/template/nontype12.C -std=c++11  (test for warnings, line 34)
>> FAIL: g++.dg/template/pseudodtor3.C -std=c++98  (test for errors, line 14)
>> FAIL: g++.dg/template/pseudodtor3.C -std=c++98  (test for errors, line 22)
>> FAIL: g++.dg/template/pseudodtor3.C -std=c++98  (test for errors, line 31)
>> FAIL: g++.dg/template/pseudodtor3.C -std=c++98  (test for errors, line 40)
>> FAIL: g++.dg/template/pseudodtor3.C -std=c++11  (test for errors, line 14)
>> FAIL: g++.dg/template/pseudodtor3.C -std=c++11  (test for errors, line 22)
>> FAIL: g++.dg/template/pseudodtor3.C -std=c++11  (test for errors, line 31)
>> FAIL: g++.dg/template/pseudodtor3.C -std=c++11  (test for errors, line 40)
>> FAIL: g++.dg/template/using16.C -std=c++98  (test for errors, line 14)
>> FAIL: g++.dg/template/using16.C -std=c++98  (test for errors, line 25)
>> FAIL: g++.dg/template/using16.C -std=c++98  (test for warnings, line 29)
>> FAIL: g++.dg/template/using16.C -std=c++11  (test for errors, line 14)
>> FAIL: g++.dg/template/using16.C -std=c++11  (test for errors, line 25)
>> FAIL: g++.dg/template/using16.C -std=c++11  (test for warnings, line 29)
>> FAIL: g++.dg/template/virtual3.C -std=c++98  (test for errors, line 8)
>> FAIL: g++.dg/gomp/block-1.C -std=c++98  (test for warnings, line 7)
>> FAIL: g++.dg/gomp/block-1.C -std=c++98  (test for warnings, line 9)
>> FAIL: g++.dg/gomp/block-1.C -std=c++11  (test for warnings, line 7)
>> FAIL: g++.dg/gomp/block-1.C -std=c++11  (test for warnings, line 9)
>> FAIL: g++.dg/gomp/block-2.C -std=c++98  (test for warnings, line 14)
>> FAIL: g++.dg/gomp/block-2.C -std=c++98  (test for warnings, line 16)
>> FAIL: g++.dg/gomp/block-2.C -std=c++11  (test for warnings, line 14)
>> FAIL: g++.dg/gomp/block-2.C -std=c++11  (test for warnings, line 16)
>> FAIL: g++.dg/gomp/block-3.C -std=c++98  (test for warnings, line 21)
>> FAIL: g++.dg/gomp/block-3.C -std=c++98  (test for warnings, line 26)
>> FAIL: g++.dg/gomp/block-3.C -std=c++98  (test for warnings, line 30)
>> FAIL: g++.dg/gomp/block-3.C -std=c++11  (test for warnings, line 21)
>> FAIL: g++.dg/gomp/block-3.C -std=c++11  (test for warnings, line 26)
>> FAIL: g++.dg/gomp/block-3.C -std=c++11  (test for warnings, line 30)
>> FAIL: g++.dg/gomp/block-5.C -std=c++98  (test for warnings, line 7)
>> FAIL: g++.dg/gomp/block-5.C -std=c++11  (test for warnings, line 7)
>> FAIL: g++.dg/gomp/for-19.C -std=gnu++98  (test for errors, line 11)
>> FAIL: g++.dg/gomp/for-19.C -std=gnu++98  (test for errors, line 29)
>> FAIL: g++.dg/gomp/for-19.C -std=gnu++98  (test for warnings, line 37)
>> FAIL: g++.dg/gomp/for-19.C -std=gnu++98  (test for warnings, line 40)
>> FAIL: g++.dg/gomp/for-19.C -std=gnu++11  (test for errors, line 11)
>> FAIL: g++.dg/gomp/for-19.C -std=gnu++11  (test for errors, line 29)
>> FAIL: g++.dg/gomp/for-19.C -std=gnu++11  (test for warnings, line 37)
>> FAIL: g++.dg/gomp/for-19.C -std=gnu++11  (test for warnings, line 40)
>> FAIL: g++.dg/gomp/pr27415.C -std=c++98  (test for errors, line 9)
>> FAIL: g++.dg/gomp/pr27415.C -std=c++98  (test for errors, line 28)
>> FAIL: g++.dg/gomp/pr27415.C -std=c++98  (test for errors, line 38)
>> FAIL: g++.dg/gomp/pr27415.C -std=c++11  (test for errors, line 9)
>> FAIL: g++.dg/gomp/pr27415.C -std=c++11  (test for errors, line 28)
>> FAIL: g++.dg/gomp/pr27415.C -std=c++11  (test for errors, line 38)
>> FAIL: c-c++-common/tm/safe-3.c -std=gnu++98 (internal compiler error)
>> FAIL: c-c++-common/tm/safe-3.c -std=gnu++98 (test for excess errors)
>> FAIL: c-c++-common/tm/safe-3.c -std=gnu++11 (internal compiler error)
>> FAIL: c-c++-common/tm/safe-3.c -std=gnu++11 (test for excess errors)
>> FAIL: g++.dg/tm/noexcept-2.C  (test for errors, line 7)
>> FAIL: g++.dg/tm/noexcept-2.C  (test for errors, line 8)
>> FAIL: g++.old-deja/g++.eh/spec6.C -std=c++98  (test for errors, line 24)
>> FAIL: g++.old-deja/g++.eh/spec6.C -std=c++98  (test for warnings, line 28)
>> FAIL: g++.old-deja/g++.eh/spec6.C -std=c++11  (test for errors, line 24)
>> FAIL: g++.old-deja/g++.eh/spec6.C -std=c++11  (test for warnings, line 28)
>> FAIL: g++.old-deja/g++.jason/report.C -std=gnu++98  (test for warnings, line 36)
>> FAIL: g++.old-deja/g++.jason/report.C -std=gnu++98  (test for warnings, line 65)
>> FAIL: g++.old-deja/g++.jason/report.C -std=gnu++11  (test for warnings, line 36)
>> FAIL: g++.old-deja/g++.jason/report.C -std=gnu++11  (test for warnings, line 65)
>> FAIL: g++.old-deja/g++.mike/net31.C -std=c++98  (test for errors, line 43)
>> FAIL: g++.old-deja/g++.mike/net31.C -std=c++11  (test for errors, line 43)
>> FAIL: g++.old-deja/g++.niklas/t135.C -std=c++98  (test for errors, line 11)
>> FAIL: g++.old-deja/g++.niklas/t135.C -std=c++98  (test for errors, line 19)
>> FAIL: g++.old-deja/g++.niklas/t135.C -std=c++11  (test for errors, line 11)
>> FAIL: g++.old-deja/g++.niklas/t135.C -std=c++11  (test for errors, line 19)
>> FAIL: g++.old-deja/g++.oliva/delete1.C -std=c++98  (test for warnings, line 31)
>> FAIL: g++.old-deja/g++.other/friend1.C -std=c++98  (test for errors, line 63)
>> FAIL: g++.old-deja/g++.other/friend1.C -std=c++98  (test for errors, line 82)
>> FAIL: g++.old-deja/g++.other/friend1.C -std=c++11  (test for errors, line 63)
>> FAIL: g++.old-deja/g++.other/friend1.C -std=c++11  (test for errors, line 82)
>> FAIL: g++.old-deja/g++.other/friend4.C -std=c++98  (test for errors, line 13)
>> FAIL: g++.old-deja/g++.other/friend4.C -std=c++98  (test for errors, line 17)
>> FAIL: g++.old-deja/g++.other/friend4.C -std=c++98  (test for errors, line 18)
>> FAIL: g++.old-deja/g++.other/friend4.C -std=c++11  (test for errors, line 13)
>> FAIL: g++.old-deja/g++.other/friend4.C -std=c++11  (test for errors, line 17)
>> FAIL: g++.old-deja/g++.other/friend4.C -std=c++11  (test for errors, line 18)
>> FAIL: g++.old-deja/g++.other/lineno1.C -std=gnu++98  (test for errors, line 9)
>> FAIL: g++.old-deja/g++.other/lineno1.C -std=gnu++11  (test for errors, line 9)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98  (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 pass (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 abort (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98  (test for warnings, line 28)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 abort (test for warnings, line 28)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 promote (test for warnings, line 30)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 abort (test for warnings, line 30)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11  (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 pass (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 abort (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11  (test for warnings, line 28)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 abort (test for warnings, line 28)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 promote (test for warnings, line 30)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 abort (test for warnings, line 30)
>> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++98  (test for errors, line 6)
>> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++98  (test for warnings, line 16)
>> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++11  (test for errors, line 6)
>> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++11  (test for warnings, line 16)
>> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++98 no def (test for errors, line 43)
>> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++98 inst (test for warnings, line 43)
>> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++11 no def (test for errors, line 43)
>> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++11 inst (test for warnings, line 43)
>> FAIL: g++.old-deja/g++.pt/instantiate8.C -std=c++98  (test for errors, line 36)
>> FAIL: g++.old-deja/g++.pt/instantiate8.C -std=c++11  (test for errors, line 36)
>> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++98  (test for errors, line 17)
>> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++98 inst (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++11  (test for errors, line 17)
>> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++11 inst (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 45)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 47)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 51)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 52)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 56)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 45)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 47)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 51)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 52)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 56)
>> FAIL: objc.dg/property/dotsyntax-17.m -fgnu-runtime  (test for errors, line 56)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98  (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 pass (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 abort (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98  (test for warnings, line 28)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 abort (test for warnings, line 28)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 promote (test for warnings, line 30)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++98 abort (test for warnings, line 30)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11  (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 pass (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 abort (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11  (test for warnings, line 28)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 abort (test for warnings, line 28)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 promote (test for warnings, line 30)
>> FAIL: g++.old-deja/g++.other/vaarg3.C -std=gnu++11 abort (test for warnings, line 30)
>> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++98  (test for errors, line 6)
>> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++98  (test for warnings, line 16)
>> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++11  (test for errors, line 6)
>> FAIL: g++.old-deja/g++.pt/crash36.C -std=c++11  (test for warnings, line 16)
>> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++98 no def (test for errors, line 43)
>> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++98 inst (test for warnings, line 43)
>> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++11 no def (test for errors, line 43)
>> FAIL: g++.old-deja/g++.pt/explicit70.C -std=c++11 inst (test for warnings, line 43)
>> FAIL: g++.old-deja/g++.pt/instantiate8.C -std=c++98  (test for errors, line 36)
>> FAIL: g++.old-deja/g++.pt/instantiate8.C -std=c++11  (test for errors, line 36)
>> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++98  (test for errors, line 17)
>> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++98 inst (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++11  (test for errors, line 17)
>> FAIL: g++.old-deja/g++.pt/vaarg3.C -std=c++11 inst (test for warnings, line 24)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 45)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 47)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 51)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 52)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++98  (test for errors, line 56)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 45)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 47)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 51)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 52)
>> FAIL: g++.old-deja/g++.robertl/eb109.C -std=c++11  (test for errors, line 56)
>> FAIL: objc.dg/property/dotsyntax-17.m -fgnu-runtime  (test for errors, line 56)
>> FAIL: objc.dg/property/dotsyntax-17.m -fgnu-runtime  (test for errors, line 58)
>> FAIL: objc.dg/property/dotsyntax-17.m -fgnu-runtime  (test for errors, line 60)
>> FAIL: objc.dg/property/dotsyntax-17.m -fgnu-runtime  (test for errors, line 62)
>> FAIL: 20_util/unique_ptr/cons/ptr_deleter_neg.cc  (test for errors, line 37)
>> FAIL: 20_util/unique_ptr/cons/ptr_deleter_neg.cc  (test for errors, line 47)
Paolo Carlini - March 27, 2012, 9:46 a.m.
Hi,
> On Mon, Mar 26, 2012 at 10:56 PM, Steven Bosscher<stevenb.gcc@gmail.com>  wrote:
>> Hello,
>>
>> This patch is one way to address PR44982. I see no good reason to
>> cgraph_finalize_compilation_unit if there were parse errors. As Richi
>> already pointed out, GCC traditionally has proceeded after parse
>> errors to preserve warnings and errors we generate from the middle-end
>> and during semantic analysis. But it seems to me that those warnings
>> are not very meaningful after parse errors (-Wuninitialized after a
>> parse error??), and errors from the middle end are mostly for exotic
>> code (involving asm()s and the like). Bailing out after parse errors
>> is therefore IMHO the right thing to do for the common case.
>>
>> Thoughts? Comments?
> Conceptually it makes sense.  Did you check whether allowing the
> FE too proceed to final_write_globals but stop before
> cgraph_finalize_compilation_unit
> preserves any errors?  I would expect that maybe FE global variable
> diagostics are defered until that?  It would be nice to finally move
> the call to cgraph_finalize_compilation_unit to the middle-end ...
> (warning, if you try that you run into an issue with the Java frontend ... :/)
I bet it does preserve some errors. I noticed that when I analyzed a bit 
PR40405, see Comment #3 in particular.

Thanks,
Paolo.
Mike Stump - March 27, 2012, 6:59 p.m.
On Mar 26, 2012, at 1:56 PM, Steven Bosscher wrote:
> This patch is one way to address PR44982.

That's a great idea, I like it.  There is only one problem that I know of that prevents it from going in now.  We emit errors/warnings from below finalize and there is a feature in which we emit all the reasonable error and warning messages that we can with one compile.  There is a certain class of power user that actually wants to see all the errors or warnings in a given compile, for them, this is a feature.  If you want to move the analysis for those to before finalize, then I think this is a good way to fix the problem, until then I think we should fix this in the normal way.  The usual way to fix this would be to find the bit that had the error_mark_node in it, and then do as much as you can, but, then to bubble up error_mark_node or otherwise end processing.

> I see no good reason to cgraph_finalize_compilation_unit if there were parse errors.

It is actually a feature people use, even if you don't have any users or your user base is too small to have ever met one.  I have.  The time the feature allows to be saved, can be measured in days and weeks.

> it seems to me that those warnings are not very meaningful after parse errors (-Wuninitialized after a
> parse error??),

But you're wrong.

int f = &sdf;

main() {
  int i;
  printf("%d", i);
}

is a program that has parse errors and certainly, any and all the errors after the first line that don't involve f in any meaningful way, are meaningful and valuable to some people.  I understand you don't see the value in them, that's all right.  They aren't valuable or meaningful to you, I get it.  But, are you willing to accept it when I assert that there is a class of people for which this is a feature, they are meaningful and valuable?

> and errors from the middle end are mostly for exotic
> code (involving asm()s and the like). Bailing out after parse errors
> is therefore IMHO the right thing to do for the common case.

Some are for very exotic things, yes, but not all of them.  Actually, I started reviewing them, none of them seem that exotic to me.  Take for example:

int f() { return this->i; }   // { dg-error "" "no member named i" } 

Really, exotic?

register int y; /* { dg-warning "file-scope declaration of 'y' specifies 'register'" } */

Again, I don't see the value in not giving the warning.

static int f2(void); /* { dg-error "used but never defined" } */

No exactly unheard of.

int x[]; /* { dg-warning "array 'x' assumed to have one element" } */

Gosh, seems reasonable.

	hash_unique_table (size_t n, hasher, key_equal,
                           value_allocator & a):table (n, a)    // { dg-error "is not a direct base" }   

This one I can see being nice to get with certain refactoring operations on large code bases.

  static_assert( I % 2 == 1, "I must be an odd number"); // { dg-error "odd number" }                    

What, you mean my static_asserts are gonna go away, but we _liked_ them.

    case low ... high : return i + 1;  // { dg-error "previously" }                                      
    case 5 : return i + 2;             // { dg-error "duplicate" }                                       

duplicate case statements, awe...  What's next?

  void Look(W& w) { w.x = 3; }          // { dg-error "private within this context" }

Bye bye access control, I guess it was overrated.

I was going to go through them all, but I have to stop now, my stomach doesn't feel well.  I was only 38% of the way though them.  Did you actually review them, all of them?

What is so very wrong with fixing this in the normal way?  I can envision beefier analysis and code checking that runs very late in the compilation process in order to get the most accurate analysis out of it.  It seems reasonable to permit that, even in the presence of parse errors, for all  the same reasons we want to see that a case statement was a duplicate, or that something was never defined.
Steven Bosscher - March 27, 2012, 7:13 p.m.
On Tue, Mar 27, 2012 at 8:59 PM, Mike Stump <mikestump@comcast.net> wrote:
>> and errors from the middle end are mostly for exotic
>> code (involving asm()s and the like). Bailing out after parse errors
>> is therefore IMHO the right thing to do for the common case.
>
> Some are for very exotic things, yes, but not all of them.  Actually, I started reviewing them, none of them seem that exotic to me.  Take for example:
>
> int f() { return this->i; }   // { dg-error "" "no member named i" }
>
> Really, exotic?

I expect it is not difficult to retain almost all of these C++ errors
by lowering (i.e. gimplifying) in the front end, or by having some
intermediate stage. It certainly wouldn't be acceptable to loose all
those diagnostics, just like that. I'm trying to figure out how to
avoid that! But it seemed prudent to ask what other people think of
this kind of change before spending loads of time on it  :-)
Thanks for your comments!

Ciao!
Steven

Patch

Index: toplev.c
===================================================================
--- toplev.c    (revision 185813)
+++ toplev.c    (working copy)
@@ -561,9 +561,14 @@  compile_file (void)
   /* Compilation is now finished except for writing
      what's left of the symbol table output.  */

-  if (flag_syntax_only || flag_wpa)
+  /* If all we have to do is syntax checking, or if there were parse
+     errors, stop here.  */
+  if (flag_syntax_only || seen_error ())
     return;

+  if (flag_wpa)
+    return;
+
   timevar_start (TV_PHASE_GENERATE);

   ggc_protect_identifiers = false;
@@ -571,12 +576,6 @@  compile_file (void)
   /* This must also call cgraph_finalize_compilation_unit.  */
   lang_hooks.decls.final_write_globals ();

-  if (seen_error ())
-    {
-      timevar_stop (TV_PHASE_GENERATE);
-      return;
-    }
-
   /* Compilation unit is finalized.  When producing non-fat LTO object, we are
      basically finished.  */
   if (in_lto_p || !flag_lto || flag_fat_lto_objects)