[Development] Clang (trunk) no longer builds Qt applications

Nicolás Alvarez nicolas.alvarez at gmail.com
Tue Oct 22 15:31:22 CEST 2013


El martes, 22 de octubre de 2013, Tobias Hunger escribió:

> I just noticed that clang from trunk is no longer able to build Qt
> applications. This is due to a change which makes clang consider "break"
> statements outside of a loop body or switch statement illegal.
>
> Unfortunately this triggers on each Q_FOREACH/foreach used by Qt
> applications!
>
> The following code:
>
> QList<QObject *> m_components << obj1 << obj2;
> foreach (QObject *component, m_components) {
>      ...
> }
>
> will get expanded to:
>
> for (QForeachContainer<__typeof__(m_components)>
> _container_(m_components); !_container_.brk && _container_.i !=
> _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; }))
> for (QObject *component = *_container_.i;; __extension__
> ({--_container_.brk; break;})) {
>      ...
> }
>
> which Clang now considers an error and will produce the following message
>
> .... error: 'break' statement not in loop or switch statement body
>
> stopping the build.
>
> Apparently that is exactly what the C++ standard requires. Based on my
> limited understanding of the details of the standard the condition in
> the for statement is not part of the loop body. Is there somebody with a
> deeper knowledge of the standard that can provide some insights here?
>

I don't think the standard is relevant here. The C++ standard doesn't and
can't say anything about whether 'break' and 'continue' are allowed in a
statement expression inside the 'for' header, because statement expressions
don't exist in the standard to begin with; they are a gcc extension. Clang
has to reverse engineer the exact semantics from gcc behavior.


-- 
Nicolás
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131022/2a21c9c6/attachment.html>


More information about the Development mailing list