From patchwork Thu Sep 29 15:10:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tristan Gingold X-Patchwork-Id: 116975 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 7FBE0100841 for ; Fri, 30 Sep 2011 01:11:25 +1000 (EST) Received: (qmail 3316 invoked by alias); 29 Sep 2011 15:11:21 -0000 Received: (qmail 3304 invoked by uid 22791); 29 Sep 2011 15:11:17 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,TW_FX X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 29 Sep 2011 15:10:57 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 1E9C0CB0366 for ; Thu, 29 Sep 2011 17:10:58 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9hm0Cq4nQJt6 for ; Thu, 29 Sep 2011 17:10:47 +0200 (CEST) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 27935CB02AE for ; Thu, 29 Sep 2011 17:10:27 +0200 (CEST) From: Tristan Gingold Subject: [Patch] Support DEC-C extensions Date: Thu, 29 Sep 2011 17:10:26 +0200 Message-Id: <51227D85-9E15-48AB-9381-14B597C1F80B@adacore.com> To: GCC Patches Mime-Version: 1.0 (Apple Message framework v1244.3) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, DEC-C, the DEC compiler provided on VMS, has added to ANSI-C at least one extension that is difficult to work-around as it is used in the system headers: varargs without named argument. It makes sense on VMS because of its ABI which pass the number of arguments used. This patch allows such declaration when the new flag -fdecc-extensions is used (C and ObjC only as C++ already allows that). I use the plural for consistency with other -fxxx-extensions and in case where others extensions are added. Bootstrapped on x86_64-darwin, no regressions. Ok for mainline ? Tristan. gcc/ 2011-09-29 Tristan Gingold * doc/invoke.texi: Document -fdecc-extensions. * c-parser.c (c_parser_parms_list_declarator): Handle -fdecc-extensions. gcc/c-family/ 2011-09-29 Tristan Gingold * c.opt (fdecc-extensions): New. gcc/testsuite/ 2011-09-29 Tristan Gingold * gcc.dg/va-arg-4.c: New test. * gcc.dg/va-arg-5.c: Ditto. diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index e6ac5dc..4879cff 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -739,6 +739,10 @@ fconstexpr-depth= C++ ObjC++ Joined RejectNegative UInteger Var(max_constexpr_depth) Init(512) -fconstexpr-depth= Specify maximum constexpr recursion depth +fdecc-extensions +C ObjC Var(flag_decc_extensions) +Enable DEC-C language extensions + fdeduce-init-list C++ ObjC++ Var(flag_deduce_init_list) Init(1) -fno-deduce-init-list disable deduction of std::initializer_list for a template type parameter from a brace-enclosed initializer-list diff --git a/gcc/c-parser.c b/gcc/c-parser.c index ff376df..788d13c 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -3159,10 +3159,19 @@ c_parser_parms_list_declarator (c_parser *parser, tree attrs, tree expr) if (c_parser_next_token_is (parser, CPP_ELLIPSIS)) { struct c_arg_info *ret = build_arg_info (); - /* Suppress -Wold-style-definition for this case. */ - ret->types = error_mark_node; - error_at (c_parser_peek_token (parser)->location, - "ISO C requires a named argument before %<...%>"); + + if (flag_decc_extensions) + { + /* F (...) is allowed by DEC-C. */ + ret->types = NULL_TREE; + } + else + { + /* Suppress -Wold-style-definition for this case. */ + ret->types = error_mark_node; + error_at (c_parser_peek_token (parser)->location, + "ISO C requires a named argument before %<...%>"); + } c_parser_consume_token (parser); if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN)) { diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e166964..1fceace 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -170,7 +170,7 @@ in the following sections. @item C Language Options @xref{C Dialect Options,,Options Controlling C Dialect}. @gccoptlist{-ansi -std=@var{standard} -fgnu89-inline @gol --aux-info @var{filename} @gol +-aux-info @var{filename} -fdecc-extensions @gol -fno-asm -fno-builtin -fno-builtin-@var{function} @gol -fhosted -ffreestanding -fopenmp -fms-extensions -fplan9-extensions @gol -trigraphs -no-integrated-cpp -traditional -traditional-cpp @gol @@ -1733,6 +1733,16 @@ fields declared using a typedef. @xref{Unnamed Fields,,Unnamed struct/union fields within structs/unions}, for details. This is only supported for C, not C++. +@item -fdecc-extensions +Accept some non-standard constructs used by DEC-C in VMS header files. + +This allows varargs functions without named argument. VMS is able to +support this feature because of its call convention which pass the +number of arguments in a register. Although it is possible to define +such a function, this is not very usefull as it is not possible to read +the arguments. This is only supported for C as this construct is +allowed by C++. + @item -trigraphs @opindex trigraphs Support ISO C trigraphs. The @option{-ansi} option (and @option{-std} diff --git a/gcc/testsuite/gcc.dg/va-arg-4.c b/gcc/testsuite/gcc.dg/va-arg-4.c new file mode 100644 index 0000000..6d737c4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/va-arg-4.c @@ -0,0 +1,3 @@ +/* { dg-do compile } */ +#include +extern void baz(...); /* { dg-error "requires a named argument" } */ diff --git a/gcc/testsuite/gcc.dg/va-arg-5.c b/gcc/testsuite/gcc.dg/va-arg-5.c new file mode 100644 index 0000000..015f592 --- /dev/null +++ b/gcc/testsuite/gcc.dg/va-arg-5.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-fdecc-extensions" } */ +#include +extern void baz(...);