[cfe-dev] <vector> parse but cannot be instanciated

Cédric Venet cedric.venet at laposte.net
Wed Sep 16 09:13:31 PDT 2009

>> (note that I am using clang on windows with the mingw 3.4.5 headers 
>> and that the define __declspec is needed. perhaps it should be added 
>> to  the predefined macro? as clang support the dllimport attribute)
> We have some support for parsing __declspec already, but I'm sure that 
> we're missing it when parsing some C++ constructs. What kinds of 
> problems are you seeing with __declspec?

It is mingw specific and not a problem on declspec. In _mingw.h, there is:

#ifndef __GNUC__
# ifndef __MINGW_IMPORT
#  define __MINGW_IMPORT  __declspec(dllimport)
# endif
# ifndef _CRTIMP
#  define _CRTIMP  __declspec(dllimport)
# endif
# define __attribute__(x) /* nothing */
#else /* __GNUC__ */
# ifdef __declspec
#  ifndef __MINGW_IMPORT
   /* Note the extern. This is needed to work around GCC's
      limitations in handling dllimport attribute.  */
#   define __MINGW_IMPORT  extern __attribute__ ((__dllimport__))
#  endif
#  ifndef _CRTIMP
#   ifdef __USE_CRTIMP
#    define _CRTIMP  __attribute__ ((dllimport))
#   else
#    define _CRTIMP
#   endif
#  endif
# else /* __declspec */
#  undef __MINGW_IMPORT
#  ifndef _CRTIMP
#   define _CRTIMP
#  endif
# endif /* __declspec */

and if __MINGW_IMPORT is not defined, there is problems latter in the 
compilation (in time.h for exemple).
So when you have __GNUC__ defined, you have to have __declspec defined, 
else it does not work. Anyway putting a define __declspec allowed me to 
parse this, even if it is a big hack)
(in fact if __MSVCRT__ can be undefined, __MINGW_IMPORT should not be 

>> now, the instanciation of the vector assert:
>> Assertion failed: false && "Unable to find declaration for the 
>> current instantiation", file 
>> ..\..\..\..\..\tools\clang\lib\Sema\SemaTemplateInstantiateDecl.cpp, 
>> line 1411
> FWIW, this is coming from an attempt to instantiate a default argument 
> expression in a template (that refers to a typedef), e.g.,

I see, thanks for the explanation. I must say I am eager to have good 
c++ semantic analyse working to be able to use clang for static analysis 
and inteligent refactoring, but I know the task is daunting so I am 
waiting. Sadly I don't have enough times to contribute (need to finish 
my phd first). just following the project is already quite time consuming :)



More information about the cfe-dev mailing list