jacob navia <> writes:
> Consider this nice C program:
>
> short long n;
> signed unsigned b;
> const long const long a;
> unsigned double w;
> signed float k;
> short double q;
> unsigned long double z;
>
> I was astonished that my dear lcc-win very bad diagnostic messages
> wrote for those errors.
>
> After correcting that, I passed this code through MSVC and it
> wrote a correct diagnostic for all of those errors... excepting
> the last.
>
> unsigned long double is legal?
>
> I have serious doubts.
No, ``unsigned long double'' is a constraint violation, as you can
verify by re-reading C99 6.7.2, Type specifiers.
> Besides, MSVC emitted just a warning for repeated qualifiers like
> "const long const long"... Isn't that an error?
No, type *specifiers* may not be repeated (other than "long long" and
variations), but type *qualifiers* such as "const" may be repeated, so
"const long const long" is equivalent to "const long long". (It's
ugly, though, so a warning seems appropriate, though it's not
required.)
C99 6.7.3p4:
If the same qualifier appears more than once in the same
_specifier-qualifier-list_, either directly or via one or more
typedefs, the behavior is the same as if it appeared only once.
The idea, I think, is that if you have a typedef for "const int", you
can still apply "const" to the typedef:
typedef const int c_int;
const c_int x = 42;
(IMHO "const" belongs on the object declaration, not buried in a
typedef, but the language allows it.)
In any case, as you know, the standard doesn't distinguish between
errors and warnings. A warning that doesn't cause translation to fail
can still be a valid "diagnostic message" as required by the standard.
> gcc wrote correct diagnostics for all of them, and all were errors,
> not warnings.
Ok, but many of gcc's required diagnostic are warnings.
> PellesC missed "const long const long" completely,
Probably because it's valid.
> but the errors
> were as I had it: just "Invalid type specification" instead of a
> more specific error.
I don't feel strongly that a more specific error message is necessary,
but that's up to you.
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"