===================================================================
@@ -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.
===================================================================
@@ -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
===================================================================
@@ -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;
+}
===================================================================
@@ -0,0 +1,2 @@
+/* { dg-do run } */
+#include "progmem-1.c"
===================================================================
@@ -0,0 +1,8 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+ extern void exit (int);
+ extern void abort (void);
+#ifdef __cplusplus
+}
+#endif
===================================================================
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-Wuninitialized" } */
+
+#include "progmem.h"
+
+const char c PROGMEM; /* { dg-warning "uninitialized variable 'c' put into program memory area" } */
===================================================================
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+#include "progmem.h"
+
+char str[] PROGMEM = "Hallo"; /* { dg-error "must be const" } */
===================================================================
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+#include "progmem.h"
+
+char str[] PROGMEM = "Hallo"; /* { dg-error "must be const" } */
===================================================================
@@ -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; }))
Georg-Johann Lay wrote: > Some runtime and checks for error/warning for C/C++. Note that some tests fail because of pending http://gcc.gnu.org/ml/gcc-patches/2011-06/msg02318.html Johann testsuite/ * gcc.target/avr/avr.exp: Run over cpp files, too. * gcc.target/avr/torture/avr-torture.exp: Ditto. * gcc.target/avr/progmem.h: New file. * gcc.target/avr/exit-abort.h: New file. * 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.