From patchwork Fri Jul 22 16:06:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 106325 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 5FAD3B6F69 for ; Sat, 23 Jul 2011 02:06:34 +1000 (EST) Received: (qmail 6045 invoked by alias); 22 Jul 2011 16:06:29 -0000 Received: (qmail 6032 invoked by uid 22791); 22 Jul 2011 16:06:26 -0000 X-SWARE-Spam-Status: No, hits=-7.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_CX X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 22 Jul 2011 16:06:06 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6MG654G022788 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 22 Jul 2011 12:06:05 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6MG65vG010816 for ; Fri, 22 Jul 2011 12:06:05 -0400 Received: from [0.0.0.0] ([10.3.113.11]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p6MG649O012383 for ; Fri, 22 Jul 2011 12:06:04 -0400 Message-ID: <4E299FEB.9020100@redhat.com> Date: Fri, 22 Jul 2011 12:06:03 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20110719 Thunderbird/5.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/49813 (c99 builtins in c++0x mode) 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 C++0x references the C99 standard, so in C++0x mode we should have the C99 builtins. Tested x86_64-pc-linux-gnu, applying to trunk. commit fc181abfe4b268602287b2cd036035ab40685b9b Author: Jason Merrill Date: Fri Jul 22 10:43:00 2011 -0400 PR c++/49813 * c-opts.c (set_std_cxx0x): Set flag_isoc94 and flag_isoc99. * c-pretty-print.c (pp_c_cv_qualifiers): Check c_dialect_cxx as well as flag_isoc99 for 'restrict'. (pp_c_specifier_qualifier_list): Likewise for _Complex. diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 5cf58ac..3227f7b 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -1488,6 +1488,9 @@ set_std_cxx0x (int iso) flag_no_gnu_keywords = iso; flag_no_nonansi_builtin = iso; flag_iso = iso; + /* C++0x includes the C99 standard library. */ + flag_isoc94 = 1; + flag_isoc99 = 1; cxx_dialect = cxx0x; } diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index 977f79e..53d39d6 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -205,7 +205,8 @@ pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, bool func_type) { if (previous) pp_c_whitespace (pp); - pp_c_ws_string (pp, flag_isoc99 ? "restrict" : "__restrict__"); + pp_c_ws_string (pp, (flag_isoc99 && !c_dialect_cxx () + ? "restrict" : "__restrict__")); } } @@ -476,7 +477,8 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t) case VECTOR_TYPE: case COMPLEX_TYPE: if (code == COMPLEX_TYPE) - pp_c_ws_string (pp, flag_isoc99 ? "_Complex" : "__complex__"); + pp_c_ws_string (pp, (flag_isoc99 && !c_dialect_cxx () + ? "_Complex" : "__complex__")); else if (code == VECTOR_TYPE) { pp_c_ws_string (pp, "__vector"); diff --git a/gcc/testsuite/g++.dg/opt/builtins2.C b/gcc/testsuite/g++.dg/opt/builtins2.C new file mode 100644 index 0000000..00a28db --- /dev/null +++ b/gcc/testsuite/g++.dg/opt/builtins2.C @@ -0,0 +1,11 @@ +// PR c++/49813 +// We should handle asinh as a built-in in C++0x mode, even when strict. +// { dg-options "-std=c++0x" } +// { dg-final { scan-assembler-not "asinh" } } + +#include + +int main() +{ + double das = asinh(1.0); +} diff --git a/gcc/testsuite/g++.dg/other/error27.C b/gcc/testsuite/g++.dg/other/error27.C index de97428..ef1e590 100644 --- a/gcc/testsuite/g++.dg/other/error27.C +++ b/gcc/testsuite/g++.dg/other/error27.C @@ -4,10 +4,10 @@ void foo (double x, double y) { - __builtin_isgreater(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" } - __builtin_isless(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" } - __builtin_isgreaterequal(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" } - __builtin_islessequal(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" } - __builtin_isunordered(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" } - __builtin_islessgreater(x, y)(); // { dg-error "__builtin_\[^\n\]*cannot be used as a function" } + __builtin_isgreater(x, y)(); // { dg-error "cannot be used as a function" } + __builtin_isless(x, y)(); // { dg-error "cannot be used as a function" } + __builtin_isgreaterequal(x, y)(); // { dg-error "cannot be used as a function" } + __builtin_islessequal(x, y)(); // { dg-error "cannot be used as a function" } + __builtin_isunordered(x, y)(); // { dg-error "cannot be used as a function" } + __builtin_islessgreater(x, y)(); // { dg-error "cannot be used as a function" } }