Index: test/Sema/attr-print.c
===================================================================
--- test/Sema/attr-print.c	(revision 0)
+++ test/Sema/attr-print.c	(revision 0)
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -ast-print | FileCheck %s
+
+// FIXME: we need to fix the "BoolArgument<"IsMSDeclSpec">"
+// hack in Attr.td for attribute "Aligned".
+
+// CHECK: int x __attribute__((aligned(4, 0)));
+int x __attribute__((aligned(4)));
+
+// CHECK: int y __attribute__((align(4, 0)));
+int y __attribute__((align(4)));
+
+// CHECK: void foo() __attribute__((const));
+void foo() __attribute__((const));
+
+// CHECK: void bar() __attribute__((__const));
+void bar() __attribute__((__const));
Index: test/SemaCXX/attr-print.cpp
===================================================================
--- test/SemaCXX/attr-print.cpp	(revision 0)
+++ test/SemaCXX/attr-print.cpp	(revision 0)
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -ast-print | FileCheck %s
+
+// FIXME: align attribute print
+
+// CHECK: int x __attribute__((aligned(4, 0)));
+int x __attribute__((aligned(4)));
+
+// CHECK: int y __attribute__((align(4, 0)));
+int y __attribute__((align(4)));
+
+// CHECK: void foo() __attribute__((const));
+void foo() __attribute__((const));
+
+// CHECK: void bar() __attribute__((__const));
+void bar() __attribute__((__const));
Index: test/SemaCXX/cxx11-attr-print.cpp
===================================================================
--- test/SemaCXX/cxx11-attr-print.cpp	(revision 0)
+++ test/SemaCXX/cxx11-attr-print.cpp	(revision 0)
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++11 -ast-print %s | FileCheck %s
+// FIXME: align attribute print
+
+// CHECK: int x __attribute__((aligned(4, 0)));
+int x __attribute__((aligned(4)));
+
+// CHECK: int y __attribute__((align(4, 0)));
+int y __attribute__((align(4)));
+
+// CHECK: gnu::aligned(4, 0)]];
+int z [[gnu::aligned(4)]];
+
+// CHECK: void foo() __attribute__((const));
+void foo() __attribute__((const));
+
+// CHECK: void bar() __attribute__((__const));
+void bar() __attribute__((__const));
+
+// CHECK: int a() __attribute__((warn_unused_result));
+int a() __attribute__((warn_unused_result));
+
+// CHECK: clang::warn_unused_result]];
+int b() [[clang::warn_unused_result]];
+
+// CHECK: gnu::warn_unused_result]];
+int c() [[gnu::warn_unused_result]];
Index: lib/Sema/SemaDeclAttr.cpp
===================================================================
--- lib/Sema/SemaDeclAttr.cpp	(revision 172543)
+++ lib/Sema/SemaDeclAttr.cpp	(working copy)
@@ -2440,7 +2440,9 @@
       return;
     }
   
-  D->addAttr(::new (S.Context) WarnUnusedResultAttr(Attr.getRange(), S.Context));
+  D->addAttr(::new (S.Context) 
+             WarnUnusedResultAttr(Attr.getRange(), S.Context,
+                                  Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleWeakAttr(Sema &S, Decl *D, const AttributeList &Attr) {
@@ -2624,7 +2626,9 @@
    if (Existing->getLocation().isInvalid())
      Existing->setRange(Attr.getRange());
   } else {
-    D->addAttr(::new (S.Context) ConstAttr(Attr.getRange(), S.Context));
+    D->addAttr(::new (S.Context) ConstAttr(Attr.getRange(), S.Context,
+                                           Attr.getAttributeSpellingListIndex()
+                                           ));
   }
 }
 
@@ -3118,16 +3122,18 @@
 
   if (Attr.getNumArgs() == 0) {
     D->addAttr(::new (S.Context) AlignedAttr(Attr.getRange(), S.Context, 
-               true, 0, Attr.isDeclspecAttribute()));
+               true, 0, Attr.isDeclspecAttribute(),
+               Attr.getAttributeSpellingListIndex()));
     return;
   }
 
   S.AddAlignedAttr(Attr.getRange(), D, Attr.getArg(0), 
-                   Attr.isDeclspecAttribute());
+                   Attr.isDeclspecAttribute(),
+                   Attr.getAttributeSpellingListIndex());
 }
 
 void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, 
-                          bool isDeclSpec) {
+                          bool isDeclSpec, unsigned SpellingListIndex) {
   // FIXME: Handle pack-expansions here.
   if (DiagnoseUnexpandedParameterPack(E))
     return;
@@ -3135,7 +3141,7 @@
   if (E->isTypeDependent() || E->isValueDependent()) {
     // Save dependent expressions in the AST to be instantiated.
     D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, true, E, 
-                                           isDeclSpec));
+                                           isDeclSpec, SpellingListIndex));
     return;
   }
   
@@ -3164,7 +3170,7 @@
   }
 
   D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, true, ICE.take(), 
-                                         isDeclSpec));
+                                         isDeclSpec, SpellingListIndex));
 }
 
 void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *TS, 
Index: include/clang/Sema/Sema.h
===================================================================
--- include/clang/Sema/Sema.h	(revision 172543)
+++ include/clang/Sema/Sema.h	(working copy)
@@ -6503,7 +6503,7 @@
 
   /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
   void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
-                      bool isDeclSpec);
+                      bool isDeclSpec, unsigned SpellingListIndex = 0);
   void AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *T,
                       bool isDeclSpec);
 
