From f2d922feb2ea93c7133d6b40317cfdce7140f74f Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 1 May 2012 20:01:48 +0000 Subject: conformtest: Unify "constant" and "typed-constant". --- conform/conformtest.pl | 59 ++++++++++++---------------------------------- conform/data/signal.h-data | 8 +++---- 2 files changed, 19 insertions(+), 48 deletions(-) (limited to 'conform') diff --git a/conform/conformtest.pl b/conform/conformtest.pl index dc3712ea66..0a1a093990 100644 --- a/conform/conformtest.pl +++ b/conform/conformtest.pl @@ -385,10 +385,11 @@ while ($#headers >= 0) { "Member \"$member\" does not have the correct type.", $res, 0); } - } elsif (/^constant *([a-zA-Z0-9_]*) *(?:([>=== 0) { : "Constant \"$const\" not available."), $res, $optional); - if (defined ($op) && ($res == 0 || !$optional)) { - # Generate a program to test for the value of this constant. + if (defined ($type) && ($res == 0 || !$optional)) { + # Test the types of the members. open (TESTFILE, ">$fnamebase.c"); print TESTFILE "$prepend"; print TESTFILE "#include <$h>\n"; - # Negate the value since 0 means ok - print TESTFILE "int main (void) { return !($const $op $value); }\n"; + print TESTFILE "__typeof__ (($type) 0) a;\n"; + print TESTFILE "extern __typeof__ ($const) a;\n"; close (TESTFILE); - $res = runtest ($fnamebase, "Testing for value of constant $const", - "Constant \"$const\" has not the right value.", $res); + compiletest ($fnamebase, "Testing for type of constant $const", + "Constant \"$const\" does not have the correct type.", + $res, 0); } - } elsif (/^typed-constant *([a-zA-Z0-9_]*) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_-]*)?/) { - my($const) = $1; - my($type) = "$3$4"; - my($value) = $5; - my($res) = $missing; - # Remember that this name is allowed. - push @allow, $const; - - # Generate a program to test for the availability of this constant. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "__typeof__ ($const) a = $const;\n"; - close (TESTFILE); - - $res = compiletest ($fnamebase, "Testing for constant $const", - "Constant \"$const\" not available.", $res, 0); - - # Test the types of the members. - open (TESTFILE, ">$fnamebase.c"); - print TESTFILE "$prepend"; - print TESTFILE "#include <$h>\n"; - print TESTFILE "__typeof__ (($type) 0) a;\n"; - print TESTFILE "extern __typeof__ ($const) a;\n"; - close (TESTFILE); - - compiletest ($fnamebase, "Testing for type of constant $const", - "Constant \"$const\" does not have the correct type.", - $res, 0); - - if ($value ne "") { + if (defined ($op) && ($res == 0 || !$optional)) { # Generate a program to test for the value of this constant. open (TESTFILE, ">$fnamebase.c"); print TESTFILE "$prepend"; print TESTFILE "#include <$h>\n"; - print TESTFILE "int main (void) { return $const != $value; }\n"; + # Negate the value since 0 means ok + print TESTFILE "int main (void) { return !($const $op $value); }\n"; close (TESTFILE); $res = runtest ($fnamebase, "Testing for value of constant $const", @@ -833,9 +806,7 @@ while ($#headers >= 0) { if (/^element *({([^}]*)}|([^ ]*)) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) { push @allow, $7; - } elsif (/^constant *([a-zA-Z0-9_]*) *(?:([>==