forked from OSchip/llvm-project
[modules] Do not report missing definitions of demoted constexpr variable templates.
This is a followup to regression introduced in r284284. This should fix our libstdc++ modules builds. https://reviews.llvm.org/D25678 Reviewed by Richard Smith! llvm-svn: 284577
This commit is contained in:
parent
9122ac994b
commit
c774a23bd9
|
@ -10124,7 +10124,11 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl,
|
|||
// C++11 [dcl.constexpr]p1: The constexpr specifier shall be applied only to
|
||||
// the definition of a variable [...] or the declaration of a static data
|
||||
// member.
|
||||
if (Var->isConstexpr() && !Var->isThisDeclarationADefinition()) {
|
||||
if (Var->isConstexpr() && !Var->isThisDeclarationADefinition() &&
|
||||
!Var->isThisDeclarationADemotedDefinition()) {
|
||||
assert((!Var->isThisDeclarationADemotedDefinition() ||
|
||||
getLangOpts().Modules) &&
|
||||
"Demoting decls is only in the contest of modules!");
|
||||
if (Var->isStaticDataMember()) {
|
||||
// C++1z removes the relevant rule; the in-class declaration is always
|
||||
// a definition there.
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef A_H
|
||||
#define A_H
|
||||
template<typename T, T v>
|
||||
struct S { static constexpr T value = v; };
|
||||
template<typename T, T v>
|
||||
constexpr T S<T, v>::value;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef B1_H
|
||||
#define B1_H
|
||||
template<typename T, T v>
|
||||
struct S { static constexpr T value = v; };
|
||||
template<typename T, T v>
|
||||
constexpr T S<T, v>::value;
|
||||
|
||||
#include "a.h"
|
||||
#endif
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef B2_H
|
||||
#define B2_H
|
||||
|
||||
template<typename T, T v>
|
||||
struct S { static constexpr T value = v; };
|
||||
template<typename T, T v>
|
||||
constexpr T S<T, v>::value;
|
||||
|
||||
#endif
|
|
@ -0,0 +1,5 @@
|
|||
module a { header "a.h" export * }
|
||||
module b {
|
||||
module b1 { header "b1.h" export * }
|
||||
module b2 { header "b2.h" export * }
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
// RUN: rm -rf %t
|
||||
// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify %s
|
||||
// RUN: %clang_cc1 -I%S/Inputs/merge-var-template-def -std=c++11 -verify -fmodules -Werror=undefined-internal -fmodules-local-submodule-visibility -fmodules-cache-path=%t -fimplicit-module-maps %s
|
||||
// expected-no-diagnostics
|
||||
|
||||
#include "b2.h"
|
||||
const bool *y = &S<bool, false>::value;
|
Loading…
Reference in New Issue