From patchwork Thu Jun 30 17:38:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 102794 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 96581B6F57 for ; Fri, 1 Jul 2011 03:42:58 +1000 (EST) Received: (qmail 28039 invoked by alias); 30 Jun 2011 17:42:56 -0000 Received: (qmail 28028 invoked by uid 22791); 30 Jun 2011 17:42:55 -0000 X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, TW_PG X-Spam-Check-By: sourceware.org Received: from mo-p00-ob.rzone.de (HELO mo-p00-ob.rzone.de) (81.169.146.162) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 30 Jun 2011 17:42:37 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT2k715jHQaJercGObUOFkj18odoYNahU4Q== X-RZG-CLASS-ID: mo00 Received: from [192.168.0.22] (business-188-111-022-002.static.arcor-ip.net [188.111.22.2]) by smtp.strato.de (klopstock mo33) (RZmta 26.0) with ESMTPA id c069c1n5UFpaD4 ; Thu, 30 Jun 2011 19:38:45 +0200 (MEST) Message-ID: <4E0CB4A5.5090606@gjlay.de> Date: Thu, 30 Jun 2011 19:38:45 +0200 From: Georg-Johann Lay User-Agent: Thunderbird 2.0.0.24 (X11/20100302) MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: Anatoly Sokolov , Denis Chertykov , Eric Weddington Subject: [testsuite, AVR]: Add some progmem test cases 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 Some runtime and checks for error/warning for C/C++. Is ./testsuite/gcc.target/avr/ realm of avr port maintainers? Johann testsuite/ * gcc.target/avr/avr.exp: Run over cpp files, too. * gcc.target/avr/torture/avr-torture.exp: Ditto. * gcc.target/avr/progmem-error-1.c: New file. * gcc.target/avr/progmem-error-1.cpp: New file. * gcc.target/avr/progmem-warning-1.c: New file. * gcc.target/avr/torture/progmem-1.c: New file. * gcc.target/avr/torture/progmem-1.cpp: New file. * gcc.target/avr/torture/progmem.h: New file. * gcc.target/avr/torture/exit-abort.h: New file. Index: gcc.target/avr/avr.exp =================================================================== --- gcc.target/avr/avr.exp (revision 175628) +++ gcc.target/avr/avr.exp (working copy) @@ -34,7 +34,7 @@ if ![info exists DEFAULT_CFLAGS] then { dg-init # Main loop. -dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \ +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{\[cCS\],cpp}]] \ "" $DEFAULT_CFLAGS # All done. Index: gcc.target/avr/torture/exit-abort.h =================================================================== --- gcc.target/avr/torture/exit-abort.h (revision 0) +++ gcc.target/avr/torture/exit-abort.h (revision 0) @@ -0,0 +1,8 @@ +#ifdef __cplusplus +extern "C" { +#endif + extern void exit (int); + extern void abort (void); +#ifdef __cplusplus +} +#endif Index: gcc.target/avr/torture/avr-torture.exp =================================================================== --- gcc.target/avr/torture/avr-torture.exp (revision 175628) +++ gcc.target/avr/torture/avr-torture.exp (working copy) @@ -52,7 +52,7 @@ set-torture-options $AVR_TORTURE_OPTIONS # Main loop. -gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] $DEFAULT_CFLAGS +gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{\[cS\],cpp}]] $DEFAULT_CFLAGS # Finalize use of torture lists. torture-finish Index: gcc.target/avr/torture/progmem-1.c =================================================================== --- gcc.target/avr/torture/progmem-1.c (revision 0) +++ gcc.target/avr/torture/progmem-1.c (revision 0) @@ -0,0 +1,30 @@ +/* { dg-do run } */ + +#include "exit-abort.h" +#include "progmem.h" + +const char strA[] PROGMEM = "@A"; +const char strc PROGMEM = 'c'; + +unsigned int volatile s = 2; + +int main() +{ + char c; + + c = pgm_read_char (&strA[s-1]); + if (c != 'A') + abort(); + + c = pgm_read_char (&PSTR ("@@B")[s]); + if (c != 'B') + abort(); + + c = pgm_read_char (&strc); + if (c != 'c') + abort(); + + exit (0); + + return 0; +} Index: gcc.target/avr/torture/progmem-1.cpp =================================================================== --- gcc.target/avr/torture/progmem-1.cpp (revision 0) +++ gcc.target/avr/torture/progmem-1.cpp (revision 0) @@ -0,0 +1,2 @@ +/* { dg-do run } */ +#include "progmem-1.c" Index: gcc.target/avr/torture/progmem.h =================================================================== --- gcc.target/avr/torture/progmem.h (revision 0) +++ gcc.target/avr/torture/progmem.h (revision 0) @@ -0,0 +1,14 @@ +#define PROGMEM __attribute__((progmem)) + +#define PSTR(s) \ + (__extension__({ \ + static const char __c[] PROGMEM = (s); \ + &__c[0];})) + +#define pgm_read_char(addr) \ + (__extension__({ \ + unsigned int __addr16 = (unsigned int)(addr); \ + char __result; \ + __asm__ ("lpm %0, %a1" \ + : "=r" (__result) : "z" (__addr16)); \ + __result; })) Index: gcc.target/avr/progmem-warning-1.c =================================================================== --- gcc.target/avr/progmem-warning-1.c (revision 0) +++ gcc.target/avr/progmem-warning-1.c (revision 0) @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized" } */ + +#include "torture/progmem.h" + +const char c PROGMEM; /* { dg-warning "uninitialized variable 'c' put into program memory area" } */ Index: gcc.target/avr/progmem-error-1.c =================================================================== --- gcc.target/avr/progmem-error-1.c (revision 0) +++ gcc.target/avr/progmem-error-1.c (revision 0) @@ -0,0 +1,5 @@ +/* { dg-do compile } */ + +#include "torture/progmem.h" + +char str[] PROGMEM = "Hallo"; /* { dg-error "must be const" } */ Index: gcc.target/avr/progmem-error-1.cpp =================================================================== --- gcc.target/avr/progmem-error-1.cpp (revision 0) +++ gcc.target/avr/progmem-error-1.cpp (revision 0) @@ -0,0 +1,5 @@ +/* { dg-do compile } */ + +#include "torture/progmem.h" + +char str[] PROGMEM = "Hallo"; /* { dg-error "must be const" } */