r284577 - [modules] Do not report missing definitions of demoted constexpr variable templates.

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 19 04:19:30 PDT 2016


Author: vvassilev
Date: Wed Oct 19 06:19:30 2016
New Revision: 284577

URL: http://llvm.org/viewvc/llvm-project?rev=284577&view=rev
Log:
[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!

Added:
    cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h
    cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h
    cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h
    cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap
    cfe/trunk/test/Modules/merge-var-template-def.cpp
Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=284577&r1=284576&r2=284577&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Oct 19 06:19:30 2016
@@ -10124,7 +10124,11 @@ void Sema::ActOnUninitializedDecl(Decl *
     // 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.

Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h?rev=284577&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/a.h Wed Oct 19 06:19:30 2016
@@ -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

Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h?rev=284577&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/b1.h Wed Oct 19 06:19:30 2016
@@ -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

Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h?rev=284577&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h (added)
+++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/b2.h Wed Oct 19 06:19:30 2016
@@ -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

Added: cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap?rev=284577&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/merge-var-template-def/module.modulemap Wed Oct 19 06:19:30 2016
@@ -0,0 +1,5 @@
+module a { header "a.h" export * }
+module b {
+  module b1 { header "b1.h" export * }
+  module b2 { header "b2.h" export * }
+}

Added: cfe/trunk/test/Modules/merge-var-template-def.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-var-template-def.cpp?rev=284577&view=auto
==============================================================================
--- cfe/trunk/test/Modules/merge-var-template-def.cpp (added)
+++ cfe/trunk/test/Modules/merge-var-template-def.cpp Wed Oct 19 06:19:30 2016
@@ -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;




More information about the cfe-commits mailing list