[cfe-dev] New C++0x feature support in Clang
Larry Evans
cppljevans at suddenlink.net
Fri Feb 4 14:39:54 PST 2011
On 02/04/11 16:23, Larry Evans wrote:
> On 02/04/11 15:45, Douglas Gregor wrote:
>>
>> On Feb 4, 2011, at 11:54 AM, Larry Evans wrote:
>>
>>> On 02/04/11 13:38, Douglas Gregor wrote:
>>>>
>>>> On Feb 4, 2011, at 11:33 AM, Larry Evans wrote:
>>>>
>>>>> On 01/26/11 15:45, Douglas Gregor wrote:
>>>>>> Clang has recently gotten much-improved support for the upcoming
>>>>>> C++0x standard. In particular, top-of-tree Clang now supports a
>>>>>> number of C++0x features:
>>>>>>
>>>>>> - Rvalue references (including rvalue references for *this)
>>>>>> - Variadic templates
>>>>>> - Inline namespaces
>>>>>> - Late-specified return types
>>>>>> - Decltype
>>>>>>
>>>>>> You can turn on C++0x support with the -std=gnu++0x (or, if you want
>>>>>> to be more pedantic, -std=c++0x).
>>>>>>
>>>>>> Give it a spin, write some tests, try it out with libc++, and tell us
>>>>>> how it went! And if you get the itch to hack on Clang, there are a
>>>>>> ton of other little C++0x features that you could implement.
>>>>>>
>>>>>> Cheers,
>>>>>> Doug
>>>>>
>>>>> How do I get the attached to compile without the
>>>>> following error about no std::move?
>>>>>
>>>>> /home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang++ -c
>>>>> -std=c++0x -U__GXX_EXPERIMENTAL_CXX0X__ -c -std=c++0x move.cpp
>>>>> move.cpp:6:16: error: no member named 'move' in namespace 'std'
>>>>> int j=std::move(i);
>>>>> ~~~~~^
>>>>
>>>> I suggest following the preprocessor logic to see what std::move isn't
>>>> getting defined. That -U__GXX_EXPERIMENTAL_CXX0X__ looks really, really
>>>> suspicious, though.
>>>
>>> The -U is there because, without it, the errors begin with:
>>>
>>> /home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang++ -c
>>> -std=c++0x -c -std=c++0x move.cpp
>>> In file included from move.cpp:1:
>>> In file included from /usr/include/c++/4.4/memory:48:
>>> In file included from /usr/include/c++/4.4/bits/stl_algobase.h:66:
>>> In file included from /usr/include/c++/4.4/bits/stl_pair.h:60:
>>> In file included from /usr/include/c++/4.4/bits/move.h:38:
>>> In file included from /usr/include/c++/4.4/type_traits:50:
>>> /usr/include/c++/4.4/tr1_impl/type_traits:233:29: error: type qualifier
>>> is not allowed on this function
>>> struct is_function<_Res(_ArgTypes...) const>
>>
>> FWIW, I implemented this extension in Clang shortly after you posted this.
>>
>> - Doug
>
> Thanks! Quick work.
>
> Did `svn update` in the llvm source and then `make` in the llvm build
> and now getting:
>
> ~/prog_dev/clang $ make HOW=clangxx move
> /home/evansl/download/llvm/svn/build/Debug+Asserts/bin/clang++ -c
> -std=c++0x -c -std=c++0x move.cpp
> In file included from move.cpp:1:
> In file included from /usr/include/c++/4.4/memory:49:
> In file included from /usr/include/c++/4.4/bits/allocator.h:48:
> In file included from
> /usr/include/c++/4.4/x86_64-linux-gnu/bits/c++allocator.h:34:
> In file included from /usr/include/c++/4.4/ext/new_allocator.h:33:
> In file included from /usr/include/c++/4.4/new:40:
> In file included from /usr/include/c++/4.4/exception:148:
> /usr/include/c++/4.4/exception_ptr.h:143:13: error: unknown type name
> 'type_info'
> const type_info*
> ^
> In file included from move.cpp:1:
> In file included from /usr/include/c++/4.4/memory:48:
> In file included from /usr/include/c++/4.4/bits/stl_algobase.h:66:
> In file included from /usr/include/c++/4.4/bits/stl_pair.h:60:
> /usr/include/c++/4.4/bits/move.h:57:14: error: rvalue reference to type
> 'typename std::remove_reference<int &>::type'
> (aka 'int') cannot bind to lvalue of type 'int'
> { return __t; }
> ^~~
> move.cpp:6:11: note: in instantiation of function template
> specialization 'std::move<int &>' requested here
> int j=std::move(i);
> ^
> 2 errors generated.
> make: *** [move] Error 1
> ~/prog_dev/clang $
Maybe I should follow the advice here:
http://clang.llvm.org/get_started.html
or more specifically the item 5:
# If you intend to work on Clang C++ support, you may need to tell it
how to find your C++ standard library headers. If Clang cannot find your
system libstdc++ headers, please follow these instructions:
* 'gcc -v -x c++ /dev/null -fsyntax-only' to get the path.
* Look for the comment "FIXME: temporary hack: hard-coded paths" in
clang/lib/Frontend/InitHeaderSearch.cpp and change the lines below to
include that path.
Is that right? I thought that it was finding the headers; hence,
I ignored this advice, but was I wrong?
TiA.
-Larry
More information about the cfe-dev
mailing list