member function void foo() __restrict__; incorrectly applies restrict to type, not pointer (original) (raw)

Bugzilla Link 17747
Version trunk
OS Linux
CC @majnemer,@DougGregor,@imallett,@rnk

Extended Description

struct Foo { void member() restrict { Foo *restrict This = this; } };

Clang gives the diagnostic:

test.cpp:3:23: error: cannot initialize a variable of type 'Foo *restrict' with
      an rvalue of type 'restrict Foo *'
    Foo *__restrict__ This = this;
                      ^      ~~~~
1 error generated.

Clang seems to think that this has type restrict Foo * (restrict on Foo, rather than the pointer)

The GCC extension says:

http://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html#Restricted-Pointers

"Within the body of T::fn, this has the effective definition T * restrict const this."