Don't allow dllimport variables in constant initializers
authorHans Wennborg <hans@hanshq.net>
Wed, 25 Jun 2014 22:19:48 +0000 (22:19 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 25 Jun 2014 22:19:48 +0000 (22:19 +0000)
commit82dd877e8a4fe1cbab27be2b067fe7724a07a875
treec0583393230e9037ebcac23a151c94417ea49892
parentc010ddb73db9a3a89ff65fb2a653daeae3744d86
Don't allow dllimport variables in constant initializers

This is a follow-up to David's r211677. For the following code,
we would end up referring to 'foo' in the initializer for 'arr',
and then fail to link, because 'foo' is dllimport and needs to be
accessed through the __imp_?foo.

  __declspec(dllimport) extern const char foo[];
  const char* f() {
    static const char* const arr[] = { foo };
    return arr[0];
  }

Differential Revision: http://reviews.llvm.org/D4299

llvm-svn: 211736
clang/lib/AST/ExprConstant.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/CodeGenCXX/dllimport.cpp
clang/test/Parser/MicrosoftExtensions.cpp
clang/test/SemaCXX/PR19955.cpp