From patchwork Mon Dec 31 14:00:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jozef Lawrynowicz X-Patchwork-Id: 1019565 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-493219-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mittosystems.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="qiH8ohzw"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mittosystems.com header.i=@mittosystems.com header.b="UkuPDUMx"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43SzVc6p6gz9rxp for ; Tue, 1 Jan 2019 01:00:54 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=gW7/gNDGUZng3JuGZ4n++EPvNZ6saCRqqSLK3rqqixHwhAw1dBTHO BsDSmUhfMuIko9EZ3yzu7hQ16UZWCq012hFr1BwutaSxNcQaKSt6V8hA0ngRlxkp BXs3GaSOR4J+GuCTgyq7ahcfeJYdbCb4jru8JSLD0zVk8bAQCx55Ms= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=cZXtUdUFKAlWEf+DzCRF3D5xZak=; b=qiH8ohzwoyJ8Kzd/vLSp 2fhmeVO5v7pgtjuMYYRhsqjJWV6TDEkVW9+NslZn5dP83LnI52VbQVmcdlhy8XAv ++3pAfIdLBFJxJXtVDsJzsxaIdrGd5dLt+ZphKadj6hLi4hGa73dR2iixSqPRkoG qAmX5V6QE4YJCFGALcbVHhU= Received: (qmail 43658 invoked by alias); 31 Dec 2018 14:00:46 -0000 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 Received: (qmail 43467 invoked by uid 89); 31 Dec 2018 14:00:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=union, 37, 87, 57 X-HELO: mail-wr1-f42.google.com Received: from mail-wr1-f42.google.com (HELO mail-wr1-f42.google.com) (209.85.221.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 31 Dec 2018 14:00:39 +0000 Received: by mail-wr1-f42.google.com with SMTP id q18so26532637wrx.9 for ; Mon, 31 Dec 2018 06:00:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mittosystems.com; s=google; h=date:from:to:subject:message-id:mime-version; bh=rueRnDnZqdxvP/ur1cJfhXnDpLYtFeRf7qqG2Es+UHE=; b=UkuPDUMxOlQHcl7NFTIhYVSup4iZL3Y53yIQ7MzqTCKHm8IEDoVHkj+xvRluISUvDG a3WnSo8h7iQoXxA+MUUAqQ8Y+oXFuk6+YGVurInLFROnMMj3VcfzwZg+BeoHabXytHOu I7hrTZiTi4YEWj98+5VpYBVfLoVxKzy70cjVHwzDLb2gNtWu/zRgwaRZ2FxUrLLUuz8e 3gXgdAklnxHHVNeC5Ljo192NzmYB4kL6Ps402alV4RUNdcMrZbfrVpLS1cf18YHrj5QP 2xse/xZWPu0d2Xii0ibH4EoliOAGLtMOhxBgGsd9zAGrj2zH508pviTvZOkWQgqiZrrL 9yUw== Received: from jozef-Aspire-VN7-793G ([2a01:4b00:87fd:900:45c9:6838:324d:b158]) by smtp.gmail.com with ESMTPSA id s66sm31725835wmf.34.2018.12.31.06.00.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Dec 2018 06:00:37 -0800 (PST) Date: Mon, 31 Dec 2018 14:00:34 +0000 From: Jozef Lawrynowicz To: Subject: [ping][PATCH][TESTSUITE] Fix ISO C errors in tests when __PTRDIFF_TYPE__ and __SIZE_TYPE__ are not ISO C compatible Message-ID: <20181231140034.634a4282@jozef-Aspire-VN7-793G> MIME-Version: 1.0 X-IsSubscribed: yes Previous submission/discussion here: https://gcc.gnu.org/ml/gcc-patches/2018-11/msg02151.html For msp430-elf with the large memory model (-mlarge), __{,U}INTPTR_TYPE__, __PTRDIFF_TYPE__ and __SIZE_TYPE__ are __int20. If a test using these macros is compiled with -pedantic-errors, and -std=* or -ansi, then GCC emits an error: ISO C does not support __int20 types The macros expand to __int20 after pre-processing, so to prevent the errors __extension__ needs to be added before their usage in the testsuite. I should clarify that using size_t/ptrdiff_t does not cause any ISO C errors, even though __int20 is the underlying type. It is only when the builtin macros for these types are used does the error occur. Successfully regtested x86_64-pc-linux-gnu and msp430-elf/-mlarge. Ok for trunk? From b940f79fa7c2a76fdda75dae7baf2bd48c72e9fa Mon Sep 17 00:00:00 2001 From: Jozef Lawrynowicz Date: Mon, 31 Dec 2018 11:36:09 +0000 Subject: [PATCH] [ping][TESTSUITE] Fix ISO C errors in tests when ptr_t/size_t are not ISO C compatible 2018-12-31 Jozef Lawrynowicz Fix ISO C errors in tests when ptr_t/size_t are not ISO C compatible gcc/testsuite/ChangeLog: * gcc.dg/addr_builtin-1.c: Add __extension__ before usage of __SIZE_TYPE__ and __UINTPTR_TYPE__. * gcc.dg/vla-11.c: Likewise. * gcc.dg/c11-static-assert-3.c: Add __extension__ before usage of __SIZE_TYPE__. * gcc.dg/c11-uni-string-1.c: Likewise. * gcc.dg/c99-const-expr-10.c: Likewise. * gcc.dg/c99-const-expr-9.c: Likewise. * gcc.dg/c99-init-1.c: Likewise. * gcc.dg/pr52549.c: Likewise. * gcc.dg/pr71558.c: Likewise. * gcc.dg/pr77587.c: Likewise. * gcc.dg/pr79223.c: Likewise. * gcc.dg/vla-9.c: Likewise. * gcc.dg/c99-const-expr-6.c: Add __extension__ before usage of __INTPTR_TYPE__. * gcc.dg/c99-stdint-5.c: Likewise. * gcc.dg/c99-stdint-6.c: Likewise. * gcc.dg/pr61240.c: Add __extension__ before usage of __PTRDIFF_TYPE__. --- gcc/testsuite/gcc.dg/addr_builtin-1.c | 6 +++--- gcc/testsuite/gcc.dg/c11-static-assert-3.c | 2 +- gcc/testsuite/gcc.dg/c11-uni-string-1.c | 2 +- gcc/testsuite/gcc.dg/c99-const-expr-10.c | 14 +++++++------- gcc/testsuite/gcc.dg/c99-const-expr-6.c | 4 ++-- gcc/testsuite/gcc.dg/c99-const-expr-9.c | 2 +- gcc/testsuite/gcc.dg/c99-init-1.c | 2 +- gcc/testsuite/gcc.dg/c99-stdint-5.c | 4 ++-- gcc/testsuite/gcc.dg/c99-stdint-6.c | 4 ++-- gcc/testsuite/gcc.dg/pr52549.c | 3 ++- gcc/testsuite/gcc.dg/pr61240.c | 2 +- gcc/testsuite/gcc.dg/pr71558.c | 8 +++++--- gcc/testsuite/gcc.dg/pr77587.c | 2 +- gcc/testsuite/gcc.dg/pr79223.c | 2 +- gcc/testsuite/gcc.dg/vla-11.c | 4 ++-- gcc/testsuite/gcc.dg/vla-9.c | 4 +++- 16 files changed, 35 insertions(+), 30 deletions(-) diff --git a/gcc/testsuite/gcc.dg/addr_builtin-1.c b/gcc/testsuite/gcc.dg/addr_builtin-1.c index 4a0888a..d7ad785 100644 --- a/gcc/testsuite/gcc.dg/addr_builtin-1.c +++ b/gcc/testsuite/gcc.dg/addr_builtin-1.c @@ -2,7 +2,7 @@ { dg-do compile } */ typedef void (F)(void); -typedef __UINTPTR_TYPE__ uintptr_t; +__extension__ typedef __UINTPTR_TYPE__ uintptr_t; /* Utility function to test passing built-in functions as an ordinary argument and via the ellipsis. */ @@ -122,7 +122,7 @@ static F* test_taking_address_of_gcc_builtin (void) of a user-declared function that's also a GCC built-in. */ extern int abs (int); -extern __SIZE_TYPE__ strlen (const char*); +__extension__ extern __SIZE_TYPE__ strlen (const char*); /* Taking the address of a builtin with a library "fallback" must be allowed, either using the __builtin_xxx form or the xxx form, when @@ -147,7 +147,7 @@ void test_taking_address_of_library_builtin (int i) } { - typedef __SIZE_TYPE__ size_t; + __extension__ typedef __SIZE_TYPE__ size_t; typedef size_t F (const char*); /* Compute the address of libc's strlen using the implicitly diff --git a/gcc/testsuite/gcc.dg/c11-static-assert-3.c b/gcc/testsuite/gcc.dg/c11-static-assert-3.c index 9799b97..25a9346 100644 --- a/gcc/testsuite/gcc.dg/c11-static-assert-3.c +++ b/gcc/testsuite/gcc.dg/c11-static-assert-3.c @@ -5,7 +5,7 @@ _Static_assert (__INT_MAX__ * 2, "overflow"); /* { dg-warning "integer overflow in expression" } */ /* { dg-error "overflow in constant expression" "error" { target *-*-* } .-1 } */ -_Static_assert ((void *)(__SIZE_TYPE__)16, "non-integer"); /* { dg-error "not an integer" } */ +_Static_assert (__extension__ (void *)(__SIZE_TYPE__)16, "non-integer"); /* { dg-error "not an integer" } */ _Static_assert (1.0, "non-integer"); /* { dg-error "not an integer" } */ diff --git a/gcc/testsuite/gcc.dg/c11-uni-string-1.c b/gcc/testsuite/gcc.dg/c11-uni-string-1.c index 9f86bea..6ace5e0 100644 --- a/gcc/testsuite/gcc.dg/c11-uni-string-1.c +++ b/gcc/testsuite/gcc.dg/c11-uni-string-1.c @@ -8,7 +8,7 @@ typedef __CHAR16_TYPE__ char16_t; typedef __CHAR32_TYPE__ char32_t; -typedef __SIZE_TYPE__ size_t; +__extension__ typedef __SIZE_TYPE__ size_t; extern void abort (void); extern void exit (int); diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-10.c b/gcc/testsuite/gcc.dg/c99-const-expr-10.c index 2aca610..0a81953 100644 --- a/gcc/testsuite/gcc.dg/c99-const-expr-10.c +++ b/gcc/testsuite/gcc.dg/c99-const-expr-10.c @@ -4,25 +4,25 @@ /* Origin: Joseph Myers */ /* { dg-do compile } */ /* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ - -void *p = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */ -struct s { void *a; } q = { (__SIZE_TYPE__)(void *)0 }; /* { dg-error "without a cast|near initialization" } */ +__extension__ typedef __SIZE_TYPE__ size_t; +void *p = (size_t)(void *)0; /* { dg-error "without a cast" } */ +struct s { void *a; } q = { (size_t)(void *)0 }; /* { dg-error "without a cast|near initialization" } */ void * f (void) { void *r; - r = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */ - return (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */ + r = (size_t)(void *)0; /* { dg-error "without a cast" } */ + return (size_t)(void *)0; /* { dg-error "without a cast" } */ } void g (void *); /* { dg-message "but argument is of type" } */ void h (void) { - g ((__SIZE_TYPE__)(void *)0); /* { dg-error "without a cast" } */ + g ((size_t)(void *)0); /* { dg-error "without a cast" } */ } void g2 (int, void *); /* { dg-message "but argument is of type" } */ void h2 (void) { - g2 (0, (__SIZE_TYPE__)(void *)0); /* { dg-error "without a cast" } */ + g2 (0, (size_t)(void *)0); /* { dg-error "without a cast" } */ } diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-6.c b/gcc/testsuite/gcc.dg/c99-const-expr-6.c index ca60243..ecb048b 100644 --- a/gcc/testsuite/gcc.dg/c99-const-expr-6.c +++ b/gcc/testsuite/gcc.dg/c99-const-expr-6.c @@ -8,7 +8,7 @@ int n = 0, p[n * 0 + 1]; /* { dg-error "variabl" } */ /* PR 31871. */ -extern int c[1 + ((__INTPTR_TYPE__) (void *) 0)]; /* { dg-error "variab" } */ +extern int c[1 + (__extension__ (__INTPTR_TYPE__) (void *) 0)]; /* { dg-error "variab" } */ /* Implicit conversions from floating-point constants are not OK, although explicit ones are. */ @@ -32,7 +32,7 @@ struct s { }; enum e { - E = (1 + ((__INTPTR_TYPE__) (void *) 0)), /* { dg-error "constant" } */ + E = (1 + (__extension__ (__INTPTR_TYPE__) (void *) 0)), /* { dg-error "constant" } */ E2 = 0 }; diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-9.c b/gcc/testsuite/gcc.dg/c99-const-expr-9.c index 11e0b2c..371e105 100644 --- a/gcc/testsuite/gcc.dg/c99-const-expr-9.c +++ b/gcc/testsuite/gcc.dg/c99-const-expr-9.c @@ -14,7 +14,7 @@ struct t { int b[2]; }; -#define old_offsetof(TYPE, MEMBER) ((__SIZE_TYPE__)(__UINTPTR_TYPE__) &((TYPE *)0)->MEMBER) +#define old_offsetof(TYPE, MEMBER) (__extension__ (__SIZE_TYPE__)(__UINTPTR_TYPE__) &((TYPE *)0)->MEMBER) enum e { E1 = old_offsetof (struct s, a), /* { dg-error "constant" } */ diff --git a/gcc/testsuite/gcc.dg/c99-init-1.c b/gcc/testsuite/gcc.dg/c99-init-1.c index 95803c2..cefcfef 100644 --- a/gcc/testsuite/gcc.dg/c99-init-1.c +++ b/gcc/testsuite/gcc.dg/c99-init-1.c @@ -3,7 +3,7 @@ /* { dg-do run } */ /* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ -typedef __SIZE_TYPE__ size_t; +__extension__ typedef __SIZE_TYPE__ size_t; typedef __WCHAR_TYPE__ wchar_t; extern int memcmp (const void *, const void *, size_t); extern void abort (void); diff --git a/gcc/testsuite/gcc.dg/c99-stdint-5.c b/gcc/testsuite/gcc.dg/c99-stdint-5.c index 6051323..97cd6f7 100644 --- a/gcc/testsuite/gcc.dg/c99-stdint-5.c +++ b/gcc/testsuite/gcc.dg/c99-stdint-5.c @@ -57,10 +57,10 @@ check_types (void) CHECK_TYPES(__UINT_FAST32_TYPE__, uint_fast32_t); CHECK_TYPES(__UINT_FAST64_TYPE__, uint_fast64_t); #ifdef __INTPTR_TYPE__ - CHECK_TYPES(__INTPTR_TYPE__, intptr_t); + CHECK_TYPES(__extension__ __INTPTR_TYPE__, intptr_t); #endif #ifdef __UINTPTR_TYPE__ - CHECK_TYPES(__UINTPTR_TYPE__, uintptr_t); + CHECK_TYPES(__extension__ __UINTPTR_TYPE__, uintptr_t); #endif CHECK_TYPES(__INTMAX_TYPE__, intmax_t); CHECK_TYPES(__UINTMAX_TYPE__, uintmax_t); diff --git a/gcc/testsuite/gcc.dg/c99-stdint-6.c b/gcc/testsuite/gcc.dg/c99-stdint-6.c index 60ac31f..1075828 100644 --- a/gcc/testsuite/gcc.dg/c99-stdint-6.c +++ b/gcc/testsuite/gcc.dg/c99-stdint-6.c @@ -60,10 +60,10 @@ check_types (void) CHECK_TYPES(__UINT_FAST64_TYPE__, uint_fast64_t); #endif #ifdef __INTPTR_TYPE__ - CHECK_TYPES(__INTPTR_TYPE__, intptr_t); + CHECK_TYPES(__extension__ __INTPTR_TYPE__, intptr_t); #endif #ifdef __UINTPTR_TYPE__ - CHECK_TYPES(__UINTPTR_TYPE__, uintptr_t); + CHECK_TYPES(__extension__ __UINTPTR_TYPE__, uintptr_t); #endif #ifndef NO_MAX_TYPES CHECK_TYPES(__INTMAX_TYPE__, intmax_t); diff --git a/gcc/testsuite/gcc.dg/pr52549.c b/gcc/testsuite/gcc.dg/pr52549.c index 4d0a3e0..faf4e5d 100644 --- a/gcc/testsuite/gcc.dg/pr52549.c +++ b/gcc/testsuite/gcc.dg/pr52549.c @@ -1,7 +1,8 @@ /* { dg-do compile } */ #ifdef __SIZE_TYPE__ -_mark (__SIZE_TYPE__ obj, int i, char *a) +__extension__ typedef __SIZE_TYPE__ size_t; +_mark (size_t obj, int i, char *a) { (char *)&(((long *)(obj)) [i]) - a; } diff --git a/gcc/testsuite/gcc.dg/pr61240.c b/gcc/testsuite/gcc.dg/pr61240.c index 6332918..8bbb347 100644 --- a/gcc/testsuite/gcc.dg/pr61240.c +++ b/gcc/testsuite/gcc.dg/pr61240.c @@ -1,7 +1,7 @@ /* PR c/61240 */ /* { dg-do compile } */ -typedef __PTRDIFF_TYPE__ ptrdiff_t; +__extension__ typedef __PTRDIFF_TYPE__ ptrdiff_t; ptrdiff_t foo (ptrdiff_t a[4]) diff --git a/gcc/testsuite/gcc.dg/pr71558.c b/gcc/testsuite/gcc.dg/pr71558.c index 33a648e..ada830b 100644 --- a/gcc/testsuite/gcc.dg/pr71558.c +++ b/gcc/testsuite/gcc.dg/pr71558.c @@ -3,15 +3,17 @@ /* strcpy must not be pure, but make sure we don't ICE even when it is declared incorrectly. */ char *strcpy (char *, const char *) __attribute__ ((__pure__)); -__SIZE_TYPE__ strlen (const char *); -void *malloc (__SIZE_TYPE__); +__extension__ typedef __SIZE_TYPE__ size_t; + +size_t strlen (const char *); +void *malloc (size_t); char a[20]; char * foo (void) { - __SIZE_TYPE__ b = strlen (a); + size_t b = strlen (a); char *c = malloc (b); return strcpy (c, a); } diff --git a/gcc/testsuite/gcc.dg/pr77587.c b/gcc/testsuite/gcc.dg/pr77587.c index 8f5afef..c4a6ebf 100644 --- a/gcc/testsuite/gcc.dg/pr77587.c +++ b/gcc/testsuite/gcc.dg/pr77587.c @@ -10,6 +10,6 @@ bar (long x, long y, long z) struct __attribute__((aligned (16))) S { long a, b, c, d; } s; char *p = (char *) &s; __asm ("" : "+r" (p)); - if (((__UINTPTR_TYPE__) p) & 15) + if ((__extension__ (__UINTPTR_TYPE__) p) & 15) __builtin_abort (); } diff --git a/gcc/testsuite/gcc.dg/pr79223.c b/gcc/testsuite/gcc.dg/pr79223.c index ef0dd1b..f043fc4 100644 --- a/gcc/testsuite/gcc.dg/pr79223.c +++ b/gcc/testsuite/gcc.dg/pr79223.c @@ -2,7 +2,7 @@ { dg-do compile } { dg-additional-options "-O2 -Wall -Wno-array-bounds -std=gnu99" } */ -typedef __SIZE_TYPE__ size_t; +__extension__ typedef __SIZE_TYPE__ size_t; extern void* memcpy (void*, const void*, size_t); extern void* mempcpy (void*, const void*, size_t); diff --git a/gcc/testsuite/gcc.dg/vla-11.c b/gcc/testsuite/gcc.dg/vla-11.c index 1504853..e2d5488 100644 --- a/gcc/testsuite/gcc.dg/vla-11.c +++ b/gcc/testsuite/gcc.dg/vla-11.c @@ -5,8 +5,8 @@ /* Origin: Joseph Myers */ /* { dg-do compile } */ /* { dg-options "-std=c99 -pedantic-errors" } */ - +__extension__ typedef __SIZE_TYPE__ size_t; void foo11a(int x[sizeof(int *(*)[*])]); /* { dg-warning "not in a declaration" } */ -void foo11b(__SIZE_TYPE__ x, int y[(__UINTPTR_TYPE__)(int (*)[*])x]); /* { dg-warning "not in a declaration" } */ +void foo11b(size_t x, int y[__extension__ (__UINTPTR_TYPE__)(int (*)[*])x]); /* { dg-warning "not in a declaration" } */ void foo11c(struct s { int (*x)[*]; } *y); /* { dg-error "a member of a structure or union cannot have a variably modified type" "variably modified" } */ /* { dg-warning "'struct s' declared inside parameter list" "struct decl" { target *-*-* } .-1 } */ diff --git a/gcc/testsuite/gcc.dg/vla-9.c b/gcc/testsuite/gcc.dg/vla-9.c index 506a1a2..44a232b 100644 --- a/gcc/testsuite/gcc.dg/vla-9.c +++ b/gcc/testsuite/gcc.dg/vla-9.c @@ -2,7 +2,9 @@ /* { dg-options "-std=c99 -pedantic-errors -W -Wall" } */ /* PR c/28280 */ -void f(__SIZE_TYPE__ d) +__extension__ typedef __SIZE_TYPE__ size_t; + +void f(size_t d) { typedef int t[d]; t *g = (__typeof (g)) d; -- 2.7.4