Add stardard definition on conform processing
Commit Message
Hi all,
This patch adds the -std=c99 option when preprocessing the data files
from the conform testcases. It fixes an issue where the compiler may
split the 'macro bool' defition from stdbool.h-data in two lines and
thus breaking the conform check.
I found this issue by debugging an unexpected failure for stdbool
while using GCC 4.8. By issuing:
$ gcc -m64 -E -P -DISO99 -x c conform/data/stdbool.h-data
macro
bool
macro-int-constant true {int} == 1
macro-int-constant false {int} == 0
macro-int-constant __bool_true_false_are_defined {int} == 1
The 'macro bool' is splitting in two lines. Talking with Joseph, it might
be a compiler issue with the altivec bool definition and thus contended
to PPC only (I haven't see it on x86_64). I'll open a GCC defect for
it.
Adding the -std=c99 fixes the macro processing. The 'c99' is uses because
the data files uses '//' comments.
To compare if any data files shows any different output while being processed
with -std=c99 (which is not expected), I used to following script:
---
#!/bin/bash
DATAFOLDER=$1
TMPDIR=`mktemp -d`
CC=gcc
CPPFLAGS="-m64 -E -P -x c"
STD="ISO ISO99 ISO11 POSIX XPG3 XPG4 UNIX98 XOPEN2K POSIX2008 XOPEN2K8"
for datafile in `find $DATAFOLDER -iname *-data`; do
for std in $STD; do
$CC -D$std $CPPFLAGS $datafile > $TMPDIR/default.out
$CC -D$std -std=c99 $CPPFLAGS $datafile > $TMPDIR/default-ansi.out
echo "$datafile | $std"
diff -u $TMPDIR/default.out $TMPDIR/default-ansi.out
done
done
---
On x86_64 I saw no difference, while on PPC64 I noted:
conform/data/stdbool.h-data | ISO99
Comments
On Tue, 18 Mar 2014, Adhemerval Zanella wrote:
> 2014-03-18 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
>
> * conform/conformtest.pl: Add standard definition when calling C
> preprocessor on data files.
> (checknamespace): Remove unused variable.
OK, thanks.
@@ -1,5 +1,4 @@
-macro
- bool
+macro bool
macro-int-constant true {int} == 1
macro-int-constant false {int} == 0
macro-int-constant __bool_true_false_are_defined {int} == 1
conform/data/stdbool.h-data | ISO11
@@ -1,5 +1,4 @@
-macro
- bool
+macro bool
macro-int-constant true {int} == 1
macro-int-constant false {int} == 0
macro-int-constant __bool_true_false_are_defined {int} == 1
conform/data/stdbool.h-data | XOPEN2K
@@ -1,5 +1,4 @@
-macro
- bool
+macro bool
macro-int-constant true {int} == 1
macro-int-constant false {int} == 0
macro-int-constant __bool_true_false_are_defined {int} == 1
conform/data/stdbool.h-data | POSIX2008
@@ -1,5 +1,4 @@
-macro
- bool
+macro bool
macro-int-constant true {int} == 1
macro-int-constant false {int} == 0
macro-int-constant __bool_true_false_are_defined {int} == 1
conform/data/stdbool.h-data | XOPEN2K8
@@ -1,5 +1,4 @@
-macro
- bool
+macro bool
macro-int-constant true {int} == 1
macro-int-constant false {int} == 0
macro-int-constant __bool_true_false_are_defined {int} == 1
Other files shows no difference.
--
2014-03-18 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* conform/conformtest.pl: Add standard definition when calling C
preprocessor on data files.
(checknamespace): Remove unused variable.
---
@@ -264,7 +264,6 @@ sub checknamespace {
close (TESTFILE);
undef %errors;
- $nknown = 0;
open (CONTENT, "$CC $CFLAGS_namespace -E $fnamebase.c -P -Wp,-dN | sed -e '/^# [1-9]/d' -e '/^[[:space:]]*\$/d' |");
loop: while (<CONTENT>) {
chop;
@@ -324,7 +323,7 @@ while ($#headers >= 0) {
printf ("Testing <$h>\n");
printf ("----------" . "-" x length ($h) . "\n");
- open (CONTROL, "$CC -E -D$standard -x c data/$h-data |");
+ open (CONTROL, "$CC -E -D$standard -std=c99 -x c data/$h-data |");
control: while (<CONTROL>) {
chop;
next control if (/^#/);