diff options
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 5 | ||||
| -rw-r--r-- | clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp | 3 | ||||
| -rw-r--r-- | clang/test/SemaCXX/attr-cxx0x.cpp | 4 |
3 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 289ec1a6f6f..2241024ba4d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2312,7 +2312,10 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, // Note that the above type specs guarantee that the // type rep is a Decl, whereas in many of the others // it's a Type. - Tag = dyn_cast<TagDecl>(TagD); + if (isa<TagDecl>(TagD)) + Tag = cast<TagDecl>(TagD); + else if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(TagD)) + Tag = CTD->getTemplatedDecl(); } if (Tag) diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp index ed98c1e9c56..bd7a5f33fd3 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p1.cpp @@ -35,6 +35,9 @@ constexpr class C1 {}; // expected-error {{class cannot be marked constexpr}} constexpr struct S1 {}; // expected-error {{struct cannot be marked constexpr}} constexpr union U1 {}; // expected-error {{union cannot be marked constexpr}} constexpr enum E1 {}; // expected-error {{enum cannot be marked constexpr}} +template <typename T> constexpr class TC1 {}; // expected-error {{class cannot be marked constexpr}} +template <typename T> constexpr struct TS1 {}; // expected-error {{struct cannot be marked constexpr}} +template <typename T> constexpr union TU1 {}; // expected-error {{union cannot be marked constexpr}} class C2 {} constexpr; // expected-error {{class cannot be marked constexpr}} struct S2 {} constexpr; // expected-error {{struct cannot be marked constexpr}} union U2 {} constexpr; // expected-error {{union cannot be marked constexpr}} diff --git a/clang/test/SemaCXX/attr-cxx0x.cpp b/clang/test/SemaCXX/attr-cxx0x.cpp index de9d7d1c2a6..5d02cfca343 100644 --- a/clang/test/SemaCXX/attr-cxx0x.cpp +++ b/clang/test/SemaCXX/attr-cxx0x.cpp @@ -9,6 +9,8 @@ struct align_member { int member alignas(8); }; +template <unsigned A> alignas(A) struct align_class_template {}; + typedef char align_typedef alignas(8); template<typename T> using align_alias_template = align_typedef; @@ -18,4 +20,6 @@ static_assert(alignof(align_multiple) == 8, "l's alignment is wrong"); static_assert(alignof(align_member) == 8, "quuux's alignment is wrong"); static_assert(sizeof(align_member) == 8, "quuux's size is wrong"); static_assert(alignof(align_typedef) == 8, "typedef's alignment is wrong"); +static_assert(alignof(align_class_template<8>) == 8, "template's alignment is wrong"); +static_assert(alignof(align_class_template<16>) == 16, "template's alignment is wrong"); static_assert(alignof(align_alias_template<int>) == 8, "alias template's alignment is wrong"); |

