+2006-12-27 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+ * src/SDCC.y (type_specifier2, pointer),
+ * src/SDCCsymt.h,
+ * src/SDCCsymt.c (mergeSpec, checkSClass),
+ * support/Util/SDCCerr.c,
+ * support/Util/SDCCerr.h: Parse and validate the restrict keyword
+ * support/valdiag/valdiag.py: Allow test cases to specify
+ required language standard
+ * support/valdiag/tests/restrict.c: New file to test restrict keyword
+ * support/valdiag/tests/tentdecl.c: Supress empty source file error
+
2006-12-27 Borut Razem <borut.razem AT siol.net>
* support/cpp2/cppmain.c, support/cpp2/mbchar.[ch]: removed
hopefully fixes #1604915 (other device libraries are still affected)
2006-12-10 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
* src/mcs51/ralloc.c (packRegsForAssign),
* src/hc08/ralloc.c (packRegsForAssign): fixed bug #1605880
SPEC_CONST(dest) |= SPEC_CONST (src);
SPEC_ABSA (dest) |= SPEC_ABSA (src);
SPEC_VOLATILE (dest) |= SPEC_VOLATILE (src);
+ SPEC_RESTRICT (dest) |= SPEC_RESTRICT (src);
SPEC_ADDR (dest) |= SPEC_ADDR (src);
SPEC_OCLS (dest) = SPEC_OCLS (src);
SPEC_BLEN (dest) |= SPEC_BLEN (src);
SPEC_VOLATILE (sym->etype) = 1;
}
+ /* make sure restrict is only used with pointers */
+ if (SPEC_RESTRICT (sym->etype))
+ {
+ werrorfl (sym->fileDef, sym->lineDef, E_BAD_RESTRICT);
+ SPEC_RESTRICT (sym->etype) = 0;
+ }
+ t = sym->type;
+ while (t)
+ {
+ if (IS_DECL (t) && DCL_PTR_RESTRICT (t) && !IS_PTR (t))
+ {
+ werrorfl (sym->fileDef, sym->lineDef, E_BAD_RESTRICT);
+ DCL_PTR_RESTRICT (t) = 0;
+ break;
+ }
+ t = t->next;
+ }
+
/* if absolute address given then it mark it as
volatile -- except in the PIC port */
unsigned b_absadr:1; /* absolute address specfied */
unsigned b_volatile:1; /* is marked as volatile */
unsigned b_const:1; /* is a constant */
+ unsigned b_restrict:1; /* is restricted */
unsigned b_typedef:1; /* is typedefed */
unsigned b_isregparm:1; /* is the first parameter */
unsigned b_isenum:1; /* is an enumerated type */
/* always 0 for flexible arrays */
unsigned ptr_const:1; /* pointer is constant */
unsigned ptr_volatile:1; /* pointer is volatile */
+ unsigned ptr_restrict:1; /* pointer is resticted */
struct sym_link *tspec; /* pointer type specifier */
}
declarator;
#define DCL_ELEM(l) validateLink(l, "DCL_ELEM", #l, DECLARATOR, __FILE__, __LINE__)->select.d.num_elem
#define DCL_PTR_CONST(l) validateLink(l, "DCL_PTR_CONST", #l, DECLARATOR, __FILE__, __LINE__)->select.d.ptr_const
#define DCL_PTR_VOLATILE(l) validateLink(l, "DCL_PTR_VOLATILE", #l, DECLARATOR, __FILE__, __LINE__)->select.d.ptr_volatile
+#define DCL_PTR_RESTRICT(l) validateLink(l, "DCL_PTR_RESTRICT", #l, DECLARATOR, __FILE__, __LINE__)->select.d.ptr_restrict
#define DCL_TSPEC(l) validateLink(l, "DCL_TSPEC", #l, DECLARATOR, __FILE__, __LINE__)->select.d.tspec
#define FUNC_DEBUG //assert(IS_FUNC(x));
#define SPEC_ISR_SAVED_BANKS(x) validateLink(x, "SPEC_NOUN", #x, SPECIFIER, __FILE__, __LINE__)->select.s._bitStart
#define SPEC_VOLATILE(x) validateLink(x, "SPEC_NOUN", #x, SPECIFIER, __FILE__, __LINE__)->select.s.b_volatile
#define SPEC_CONST(x) validateLink(x, "SPEC_NOUN", #x, SPECIFIER, __FILE__, __LINE__)->select.s.b_const
+#define SPEC_RESTRICT(x) validateLink(x, "SPEC_NOUN", #x, SPECIFIER, __FILE__, __LINE__)->select.s.b_restrict
#define SPEC_STRUCT(x) validateLink(x, "SPEC_NOUN", #x, SPECIFIER, __FILE__, __LINE__)->select.s.v_struct
#define SPEC_TYPEDEF(x) validateLink(x, "SPEC_NOUN", #x, SPECIFIER, __FILE__, __LINE__)->select.s.b_typedef
#define SPEC_REGPARM(x) validateLink(x, "SPEC_NOUN", #x, SPECIFIER, __FILE__, __LINE__)->select.s.b_isregparm
DCL_TYPE(x) == CPOINTER || \
DCL_TYPE(x) == UPOINTER ))
#define IS_PTR_CONST(x) (IS_PTR(x) && DCL_PTR_CONST(x))
+#define IS_PTR_RESTRICT(x) (IS_PTR(x) && DCL_PTR_RESTRICT(x))
#define IS_FARPTR(x) (IS_DECL(x) && DCL_TYPE(x) == FPOINTER)
#define IS_CODEPTR(x) (IS_DECL(x) && DCL_TYPE(x) == CPOINTER)
#define IS_GENPTR(x) (IS_DECL(x) && DCL_TYPE(x) == GPOINTER)
"ISO C forbids an empty source file" },
{ W_BAD_PRAGMA_ARGUMENTS, ERROR_LEVEL_WARNING,
"#pragma %s: bad argument(s); pragma ignored" },
+{ E_BAD_RESTRICT, ERROR_LEVEL_ERROR,
+ "Only pointers may be qualified with 'restrict'" },
};
/*
#define E_FLEXARRAY_INEMPTYSTRCT 189 /* flexible array in otherwise empty struct */
#define W_EMPTY_SOURCE_FILE 190 /* ISO C forbids an empty source file */
#define W_BAD_PRAGMA_ARGUMENTS 191 /* #pragma %s: bad argument(s); pragma ignored */
-
+#define E_BAD_RESTRICT 192 /* Only pointers may be qualified with 'restrict' */
#define MAX_ERROR_WARNING 256 /* size of disable warnings array */
/** Describes the maximum error level that will be logged. Any level
--- /dev/null
+
+/* The restrict keyword can only qualify pointers */
+
+#ifdef TEST1_C99
+restrict a; /* ERROR */
+#endif
+
+#ifdef TEST2_C99
+restrict int a; /* ERROR */
+#endif
+
+#ifdef TEST3_C99
+restrict int a[10]; /* ERROR */
+#endif
+
+#ifdef TEST4_C99
+restrict int * a; /* ERROR */
+#endif
+
+#ifdef TEST5_C99
+restrict struct
+ {
+ int a;
+ int b;
+ } x; /* ERROR */
+#endif
+
+#ifdef TEST6_C99
+restrict int func(void) { /* ERROR */
+ return 0;
+}
+#endif
+
+#ifdef TEST7_C99
+void func(restrict int x) { /* ERROR */
+ x; /* IGNORE */
+}
+#endif
+
+
+#ifdef TEST_GOOD1_C99
+int * restrict a;
+#endif
+
+#ifdef TEST_GOOD2_C99
+int * func(int * restrict x)
+{
+ return x;
+}
+#endif
+
+#ifdef TEST_GOOD3_C99
+void func(int * restrict x)
+{
+ x; /* IGNORE */
+}
+#endif
volatile XDATA int a; /* ERROR(SDCC && !(__z80 || __gbz80)) */
#endif
#endif
+
+int validDeclaraction; /* to make sure this is never an empty source file */
"CCFLAGS":"-c -Wall -DPORT_HOST=1",
"CCDEF":"-D",
"CCOUTPUT":"-o",
+ "C89":"-std=c89",
+ "C99":"-std=c99",
"defined": {
"__GNUC__":"1",
"GCC":"1"
"CCFLAGS":"-c -m{port}",
"CCDEF":"-D",
"CCOUTPUT":"-o",
+ "C89":"--std-sdcc89",
+ "C99":"--std-sdcc99",
"defined": {
"SDCC":"1",
"SDCC_{port}":"1",
for testname in testcases.keys():
ccdef = compilermode["CCDEF"]+testname
- cmd = string.join([cc,ccflags,ccdef,inputfilename])
+ if testname[-3:] == "C89":
+ ccstd = compilermode["C89"]
+ elif testname[-3:] == "C99":
+ ccstd = compilermode["C99"]
+ else:
+ ccstd = ""
+ cmd = string.join([cc,ccflags,ccstd,ccdef,inputfilename])
print
print cmd
spawn = popen2.Popen4(cmd)