]> granicus.if.org Git - clang/commit
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)
commit7a08bd78a5be9410fa910961f001e157f68f2e6f
tree320b485d5c50cea95dba1bcd3fc6130a451b3035
parent85fb905d517e07b0322fee8236e7b3314fb799aa
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211736 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/ExprConstant.cpp
lib/Sema/SemaTemplate.cpp
test/CodeGenCXX/dllimport.cpp
test/Parser/MicrosoftExtensions.cpp
test/SemaCXX/PR19955.cpp