From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78375 invoked by alias); 27 Apr 2015 16:04:10 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 78349 invoked by uid 48); 27 Apr 2015 16:04:07 -0000 From: "mpolacek at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/65901] no warning or error for va_arg (ap, void) Date: Mon, 27 Apr 2015 16:04:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: mpolacek at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 6.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-04/txt/msg02306.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65901 --- Comment #2 from Marek Polacek --- Untested patch: --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -12648,6 +12648,11 @@ c_build_va_arg (location_t loc, tree expr, tree type) if (warn_cxx_compat && TREE_CODE (type) == ENUMERAL_TYPE) warning_at (loc, OPT_Wc___compat, "C++ requires promoted type, not enum type, in %"); + if (type == error_mark_node || !COMPLETE_TYPE_P (type)) + { + c_incomplete_type_error (NULL_TREE, type); + return error_mark_node; + } return build_va_arg (loc, expr, type); }