aboutsummaryrefslogtreecommitdiff
path: root/gnattools
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2019-12-04 23:26:10 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2019-12-04 23:26:10 +0000
commit4691bf46e3572dec2040a4ac59b9e9e279b827d7 (patch)
tree0bc763be30e740b45f4af65fde1f52977102431c /gnattools
parentf30025bb34ca110653f517efd6d6193cc8bac1aa (diff)
downloadgcc-4691bf46e3572dec2040a4ac59b9e9e279b827d7.zip
gcc-4691bf46e3572dec2040a4ac59b9e9e279b827d7.tar.gz
gcc-4691bf46e3572dec2040a4ac59b9e9e279b827d7.tar.bz2
Fix C handling of use of lvalues of incomplete types (PR c/36941, PR c/88827).
Bug 88827 points out that GCC should not be rejecting C code that dereferences a pointer to an incomplete type in the case that uses &* to take the address of the resulting lvalue, because no constraint is violated in that case (other than for C90 when the incomplete type is unqualified void, which we already handle correctly) and as the lvalue never gets converted to an rvalue there is no undefined behavior either. This means that the diagnostic for such a dereference is bogus and should be removed; if the lvalue gets converted to an rvalue, there should be an appropriate error later for the use of the incomplete type. In most cases, there is, but bug 36941 points out the lack of a diagnostic when the incomplete (non-void) type gets cast to void (where a diagnostic seems appropriate for this undefined behavior as a matter of quality of implementation). This patch removes the bogus diagnostic (and C_TYPE_ERROR_REPORTED which was only used in the code that is removed - only that one, bogus diagnostic had this duplicate suppression, not any of the other, more legitimate diagnostics for use of incomplete types) and makes convert_lvalue_to_rvalue call require_complete_type for arguments not of void types, so that all relevant code paths (possibly except some for ObjC) get incomplete types diagnosed. It's possible that this makes some other checks for incomplete types obsolete, but no attempt is made to remove any such checks. Bootstrapped with no regressions for x86_64-pc-linux-gnu. PR c/36941 PR c/88827 gcc/c: * c-typeck.c (convert_lvalue_to_rvalue): Call require_complete_type for arguments not of void types. (build_indirect_ref): Do not diagnose dereferencing pointers to incomplete types. * c-tree.h (C_TYPE_ERROR_REPORTED): Remove. gcc/testsuite: * gcc.dg/lvalue-9.c, gcc.dg/lvalue-10.c: New tests. * gcc.dg/array-8.c, gcc.dg/enum-incomplete-1.c, gcc.dg/enum-incomplete-3.c, gcc.dg/noncompile/incomplete-3.c, gcc.dg/pr48552-1.c, gcc.dg/pr48552-2.c, gcc.dg/pr63543.c, gcc.dg/pr69796.c: Update expected diagnostics. From-SVN: r278976
Diffstat (limited to 'gnattools')
0 files changed, 0 insertions, 0 deletions