On 30/01/15 22:21, Emil Velikov wrote:
On 30/01/15 20:02, Jose Fonseca wrote:
On 30/01/15 16:25, Emil Velikov wrote:
On 30 January 2015 at 11:07, Jose Fonseca <jfons...@vmware.com> wrote:
Workaround what seems to be a bug in MSVC parser for C99.

https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_archives_waffle_2015-2DJanuary_000975.html&d=AwIBaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=EOTSIhn-7yCkuKuQ-JCDhS7EtrWFaozBDxo228XaWso&s=0Bi5_OB7Grl7-w1RO8R0l0YtCyi9IkRu-lB9Jtt7Ono&e=

Should have spotted this a Frank sent out the patch. Sorry about this
Jose.
Reviewed-by: Emil Velikov <emil.l.veli...@gmail.com>

Wondering if we should (as a follow up commit) move the variable
declarations prior to the code to avoid such fun in the future ?

It's hard to say.

It looks like MSVC allows declarations in the middle of blocks, but the
parser gets into a wierd state some times.

 From my earlier experience this issue happens as the variable type is a
typedef or a struct. For simple types such as int, float, etc. I've not
seen such problems. Or was it when the declaration is initialised
(with/wo a designated initializer) ?

I think the surer way long term would be to report the MSVC bug to
Microsoft.  There have been positive experiences in the past [1] [2]

Good point. I'll put it on my list but I don't even have an live/msdn
account :\ I'm not sure when I'll get around to creating one, so if
anyone is interested the following mock-up should be able to visualise
the problem(s).


#include <stdio.h>
#include <stdlib.h>

struct foo {
    int i;
};

typedef int bar;

int
main(void)
{
    struct foo foo1 = { .i = 1 };
    printf("foo1 %d\n", foo1.i);
// ^^
// The preprocessor/compiler will throw an error here.

    struct foo foo2 = { .i = 2 };
    printf("foo2 %d\n", foo2.i);
// ^^
// The preprocessor/compiler will throw an error here.

    bar bar1 = 1;
    printf("bar1 %d\n", bar1);

    return 0;
}


Cheers,
Emil

Thanks for isolating a test case Emil.

I have good news: MSVC 2013 Update 4 seems to have fixed the issue, so we don't need to file a bug after all.

Given that waffle requires C99, it basically requires MSVC 2013. And given that MSVC 2013 U4 is a free update it seems acceptable to require it too. (This is what I'm proposing for piglit too BTW)


Jose
_______________________________________________
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle

Reply via email to