Index: test/Sema/attr-deprecated.c
===================================================================
--- test/Sema/attr-deprecated.c	(revision 122615)
+++ test/Sema/attr-deprecated.c	(working copy)
@@ -43,7 +43,8 @@
 foo_dep *test2;    // expected-warning {{'foo_dep' is deprecated}}
 
 struct bar_dep __attribute__((deprecated, 
-                              invalid_attribute));  // expected-warning {{unknown attribute 'invalid_attribute' ignored}}
+                              invalid_attribute));  // expected-warning {{unknown attribute 'invalid_attribute' ignored}} \
+// expected-warning {{attribute is ignored;  place it after "struct" to apply it to the type declaration}}
 
 struct bar_dep *test3;   // expected-warning {{'bar_dep' is deprecated}}
 
Index: test/Sema/warn-cast-align.c
===================================================================
--- test/Sema/warn-cast-align.c	(revision 122615)
+++ test/Sema/warn-cast-align.c	(working copy)
@@ -28,7 +28,7 @@
 }
 
 // Aligned struct.
-__attribute__((align(16))) struct A {
+struct __attribute__((align(16))) A {
   char buffer[16];
 };
 void test2(char *P) {
Index: test/Sema/attr-declspec-ignored.c
===================================================================
--- test/Sema/attr-declspec-ignored.c	(revision 0)
+++ test/Sema/attr-declspec-ignored.c	(revision 0)
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// These should warn on ignored attributes in declspec.
+__attribute__((align(16))) // expected-warning {{attribute is ignored;  place it after "struct" to apply it to the type declaration}}
+struct A;
+__attribute__((align(16))) // expected-warning {{attribute is ignored;  place it after "union" to apply it to the type declaration}}
+union B;
+__attribute__((align(16))) // expected-warning {{attribute is ignored;  place it after "enum" to apply it to the type declaration}}
+enum C;
+
+// These should not warn as attributes are placed correctly.
+struct __attribute__((align(16))) A;
+union __attribute__((align(16))) B;
+enum __attribute__((align(16))) C;
+
+// These should not warn because attributes are applying to the declarator
+__attribute__((align(16)))
+struct A {} A;
+__attribute__((align(16)))
+union B {} B;
+__attribute__((align(16)))
+enum C {C} c;
+
+
Index: test/SemaCXX/attr-declspec-ignored.cpp
===================================================================
--- test/SemaCXX/attr-declspec-ignored.cpp	(revision 0)
+++ test/SemaCXX/attr-declspec-ignored.cpp	(revision 0)
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// These should warn on ignored attributes in declspec.
+__attribute__((visibility("default"))) // expected-warning {{attribute is ignored;  place it after "struct" to apply it to the type declaration}}
+struct A;
+__attribute__((visibility("default"))) // expected-warning {{attribute is ignored;  place it after "union" to apply it to the type declaration}}
+union B;
+__attribute__((visibility("default"))) // expected-warning {{attribute is ignored;  place it after "enum" to apply it to the type declaration}}
+enum C {C};
+__attribute__((visibility("default"))) // expected-warning {{attribute is ignored;  place it after "class" to apply it to the type declaration}}
+class D;
+
+// These should not warn as attributes are placed correctly.
+struct __attribute__((visibility("default")))  A;
+union __attribute__((visibility("default")))  B;
+enum __attribute__((visibility("default")))  C1 {C1};
+class __attribute__((visibility("default")))  D;
+
+// These should not warn because attributes are applying to the declarator
+__attribute__((visibility("default"))) 
+struct A {} A;
+__attribute__((visibility("default"))) 
+union B {} B;
+__attribute__((visibility("default"))) 
+enum C2 {C2} c;
+__attribute__((visibility("default"))) 
+class D {} d;
+
+
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td	(revision 122615)
+++ include/clang/Basic/DiagnosticSemaKinds.td	(working copy)
@@ -987,6 +987,8 @@
 def warn_redeclaration_without_attribute_prev_attribute_ignored : Warning<
   "'%0' redeclared without %1 attribute: previous %1 ignored">;
 def warn_attribute_ignored : Warning<"%0 attribute ignored">;
+def warn_attribute_in_declspec_ignored : Warning<
+  "attribute is ignored;  place it after \"%select{class|struct|union|enum}0\" to apply it to the type declaration">;
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup<UnknownAttributes>;
 def warn_attribute_precede_definition : Warning<
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp	(revision 122615)
+++ lib/Sema/SemaDecl.cpp	(working copy)
@@ -1622,6 +1622,18 @@
     // type rep is a Decl, whereas in many of the others
     // it's a Type.
     Tag = dyn_cast<TagDecl>(TagD);
+
+    // Warn about ignored attributes in the declspec with no
+    // declarator. To apply attributes on type declaration,
+    // the attributes should be placed after keywords of user
+    // defined types.
+    if (DS.getAttributes().getList()) {
+    Diag(DS.getAttributes().getList()->getLoc(), diag::warn_attribute_in_declspec_ignored) 
+      << (DS.getTypeSpecType() == DeclSpec::TST_class? 0
+          : DS.getTypeSpecType() == DeclSpec::TST_struct? 1
+          : DS.getTypeSpecType() == DeclSpec::TST_union? 2
+          : 3);
+    }
   }
 
   if (unsigned TypeQuals = DS.getTypeQualifiers()) {
