Clang: QT header compilation error

Hi,

While I was running clang on a QT code, It flagged a compilation error in a standard QT header file.

image001.jpg

qvector.h (26.2 KB)

Hi Sujit,

Unfortunately, the header file alone is not helpful. It is not
obvious what Q_TYPENAME expands to. Could you please provide a
preprocessed file? (Just replace -c with -E on the compilation
command line that is failing.)

Dmitri

At a glance (given the diagnostic and the macro) I suppose that Q_TYPENAME should have expanded into typename (which would have made the code correct) and did not.

As such, the preprocessed source will only be of moderate usefulness (confirming the diagnosis) and we will also need the definition of this Q_TYPENAME macro. It’s probably defined differently depending on the platform and mistake clang for a non-compliant compiler.

– Matthieu

Matthieu Monrocq wrote:

>
> Hi,
>
> While I was running clang on a QT code, It flagged a compilation error
> in a standard QT header file.
>
> include\QtCore/qvector.h:565:12: error: missing 'typename'
>
> prior to dependent type name 'QVector<T>::iterator'
>
> Q_TYPENAME QVector<T>::iterator QVector<T>::insert(iterator before,...
>
> ^~~~~~~~~~~~~~~~~~~~
>
> include\QtCore/qvector.h:599:12: error: missing 'typename'
>
> prior to dependent type name 'QVector<T>::iterator'
>
> Q_TYPENAME QVector<T>::iterator QVector<T>::erase(iterator abegin,...
>
> ^~~~~~~~~~~~~~~~~~~~
>
>
>
> Attaching the header file along.

Hi Sujit,

Unfortunately, the header file alone is not helpful. It is not
obvious what Q_TYPENAME expands to. Could you please provide a
preprocessed file? (Just replace -c with -E on the compilation
command line that is failing.)

Dmitri

--
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko
<gribozavr@gmail.com>*/
_______________________________________________ cfe-dev mailing list
cfe-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

At a glance (given the diagnostic and the macro) I suppose that Q_TYPENAME
should have expanded into typename (which would have made the code
correct) and did not.

As such, the preprocessed source will only be of moderate usefulness
(confirming the diagnosis) and we will also need the definition of this
Q_TYPENAME macro. It's probably defined differently depending on the
platform and mistake clang for a non-compliant compiler.

-- Matthieu

I tried to reproduce this in my Qt 4 build, but I could not reproduce it:

stephen@hal:~/dev/prefix/qt48/include$ clang++ -I. -E QtCore/qvector.h >
out
clang-3: warning: treating 'c-header' input as 'c++-header' when in C++
mode, this behavior is deprecated
stephen@hal:~/dev/prefix/qt48/include$ l
out Qt3Support/ QtDBus/ QtDesigner/ QtHelp/ QtNetwork/
QtScript/ QtSql/ QtTest/ QtWebKit/ QtXmlPatterns/
Qt/ QtCore/ QtDeclarative/ QtGui/ QtMultimedia/ QtOpenGL/
QtScriptTools/ QtSvg/ QtUiTools/ QtXml/

From my reading qglobal.h, Q_TYPENAME should be 'typename' everywhere except

some ancient DEC C++ and ancient xlC compilers.

Thanks,

Steve.

Right. The macro has even been removed in Qt trunk (and replaced by
direct uses of 'typename'). It seems very unlikely this is a problem
in Clang.

Hi Matthieu, Dmitri,

Attaching the text file (log.txt) which has the output generated by command using –E option.

After some time clang thrown an exception and stopped working.

The console output is:

files.zip (666 KB)

Hi Matthieu, Dmitri,

I had sent some more inputs in attachments.

The email is being held until moderators approve it.

Unfortunately, I could not reproduce the crash, but the preprocessed
file you sent confirmed Matthieu's diagnosis. The file contains:

# if _MSC_VER < 1310
# define QT_NO_QOBJECT_CHECK
# define Q_TYPENAME

And Clang defines _MSC_VER to 1300. But in my opinion this code path
should not be executed for Clang because Qt 4.7.4 has support for
Clang, one should just select appropriate compiler configuration
(during Qt compilation?).

There's also a bug in our crash report generation. Note the
mismatched quotes and the inappropriate "Files\\..." part in:

"D:/CBA/CONTI_OVIP_Vehicle/setup/CheckMate/CheckMate_Tool/clang++.exe"
-cc1 -triple i686-pc-win32 -E -disable-free -disable-llvm-verifier
-main-file-name XvvHmiLogic.cpp -mrelocation-model static
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-target-cpu pentium4 -momit-leaf-frame-pointer Files\\Microsoft Visual
Studio 9.0\\VC\\include" Files\\Microsoft
SDKs\\Windows\\v6.0A\\\\include" -std=c++11 -fdeprecated-macro
-ferror-limit 19 -fmessage-length 80 -mstackrealign -fms-extensions
-fms-compatibility -fmsc-version=1300 -fdelayed-template-parsing
-fobjc-runtime=gcc -fobjc-default-synthesize-properties
-fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -x c++ XvvHmiLogic-246825.cpp

Dmitri

Hi Dmitri,
So what do you suggest me so that I can get rid of this error message?

Regards,
Sujit Kamthe
BuildBox>KPITCummins Infosystems Ltd|Extn:3102 |Mobile:7709076120

Sorry, but I am not sure. I know that Qt supports choosing the
platform while compiling Qt itself, something like:

./configure -xplatform win32-clang-linux ...

But I don't know if it is relevant here (e.g., if the binary
distribution of Qt for Windows should support Clang out-of-the box and
one should change something else).

Dmitri