diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-14 19:58:02 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-14 19:58:02 +0000 |
| commit | 465841e48c929f840e83bf34d581ad88e05ed620 (patch) | |
| tree | 87bbb5c2767f5f5a2267f95ba9edd81f52595846 /clang | |
| parent | 450128a68c4d13119e6d385e6be406cbb4c4049d (diff) | |
| download | bcm5719-llvm-465841e48c929f840e83bf34d581ad88e05ed620.tar.gz bcm5719-llvm-465841e48c929f840e83bf34d581ad88e05ed620.zip | |
[temp.explicit]p1: constexpr cannot be specified in explicit instantiations.
llvm-svn: 141982
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 9 | ||||
| -rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp | 9 |
3 files changed, 15 insertions, 5 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index a3a423d9d75..4051a806387 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -2412,6 +2412,8 @@ def note_explicit_instantiation_candidate : Note< "explicit instantiation candidate function template here %0">; def err_explicit_instantiation_inline : Error< "explicit instantiation cannot be 'inline'">; +def err_explicit_instantiation_constexpr : Error< + "explicit instantiation cannot be 'constexpr'">; def ext_explicit_instantiation_without_qualified_id : Extension< "qualifier in explicit instantiation of %q0 requires a template-id " "(a typedef is not permitted)">; diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 929d74efa98..8dda34c8ab5 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -6164,9 +6164,12 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, if (D.getDeclSpec().isInlineSpecified() && getLangOptions().CPlusPlus0x) Diag(D.getDeclSpec().getInlineSpecLoc(), diag::err_explicit_instantiation_inline) - <<FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc()); - - // FIXME: check for constexpr specifier. + << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc()); + if (D.getDeclSpec().isConstexprSpecified()) + // FIXME: Add a fix-it to remove the 'constexpr' and add a 'const' if one is + // not already specified. + Diag(D.getDeclSpec().getConstexprSpecLoc(), + diag::err_explicit_instantiation_constexpr); // C++0x [temp.explicit]p2: // There are two forms of explicit instantiation: an explicit instantiation diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp index e898a489682..97e78fd791f 100644 --- a/clang/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p1-0x.cpp @@ -5,6 +5,11 @@ struct X { void f() {} }; -template inline void X<int>::f(); // expected-error{{'inline'}} +template inline void X<int>::f(); // expected-error{{explicit instantiation cannot be 'inline'}} -// FIXME: test constexpr +template<typename T> +struct Y { + constexpr int f() { return 0; } +}; + +template constexpr int Y<int>::f(); // expected-error{{explicit instantiation cannot be 'constexpr'}} |

