[cfe-dev] <vector> parse but cannot be instanciated
Douglas Gregor
dgregor at apple.com
Wed Sep 16 09:46:08 PDT 2009
On Sep 16, 2009, at 9:13 AM, Cédric Venet wrote:
>
>>
>>> (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 __DECLSPEC_SUPPORTED
> # 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
> # define __DECLSPEC_SUPPORTED
> # else /* __declspec */
> # undef __DECLSPEC_SUPPORTED
> # 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 used...)
Okay, so we need to be defining __declspec on mingw targets. That
involves creating a new target for MinGW32/64 (in lib/Basic/
Targets.cpp) that adds these defines into its getTargetDefines()
function. The actual spelling of the predefined __declspec (and any
other mingw-specific macros) will be shown in the output of
touch foo.cpp
g++ -dM -E foo.cpp
>>
>>> 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.
We're inching closer :)
- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090916/39bdb59e/attachment.html>
More information about the cfe-dev
mailing list